hiiii,
I have searched and found it.
I am giving my xslt file here if anybody need it ,
<
?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:asp="remove">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<asp:GridView runat="server">
<xsl:attribute name="ID">
<xsl:text >grd</xsl:text>
<xsl:value-of select ="table/TableName"/>
</xsl:attribute>
<xsl:for-each select ="table/Columns">
<xsl:for-each select="child::*">
<xsl:variable name="ColumnN">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:variable name="DataType">
<xsl:value-of select="@dataType"/>
</xsl:variable>
<xsl:variable name="isPK">
<xsl:value-of select="@isPrimaryKey"/>
</xsl:variable>
<xsl:variable name="isFK">
<xsl:value-of select="@isForeignKey"/>
</xsl:variable>
<xsl:if test ="$isPK='false' and $DataType!='date'">
<asp:TemplateField HeaderText="{$ColumnN}">
<ItemTemplate>
<xsl:text>'<#%Eval(</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>)%>' </xsl:text>
</ItemTemplate>
</asp:TemplateField>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</asp:GridView>
</xsl:template>
</xsl:stylesheet>
here first I have created an xml document of my table(any table)
this is look like
<
?xml version="1.0"?>
<table>
<TableName>AdminLogin</TableName>
<Columns>
<ColumnName name="UserName" dataType="varchar" IsNull="NO" length="50" isPrimaryKey="false" isForeignKey="false" />
<ColumnName name="Password" dataType="varchar" IsNull="NO" length="50" isPrimaryKey="false" isForeignKey="false" />
<ColumnName name="CreatedOn" dataType="date" IsNull="NO" length="" isPrimaryKey="false" isForeignKey="false" />
<ColumnName name="Id" dataType="int" IsNull="NO" length="" isPrimaryKey="true" isForeignKey="false" />
</Columns>
</table>
and generating normal aspx from tranforming that xslt
in cs I wrote
XslFile = @"XSLT\GridView.xslt";
xdoc = gn.GenerateTableSchema(drpTable.SelectedValue.ToString());
XsltArgumentList xslarg = new XsltArgumentList();
XslTransform xsl = new XslTransform();
xsl.Load(XslFile);
StringWriter sw = new StringWriter();
xsl.Transform(xdoc, xslarg, sw);
string result = sw.ToString().Replace("xmlns:asp=\"remove\"",
"").Replace("<", "<").Replace(">", ">");
// free up the memory of objects that are not used anymore
string result1 = sw.ToString().Replace("xmlns:asp=\"remove\"",
"").Replace("<", "<").Replace(">", ">");
sw.Close();
txtAns.Text = result1;
just run it ... in txtAns textbox displays gridview control.
try it and generate many controls.
Happy Programming!!
Rohi
RohiK, if this helps please login to Mark As Answer. | Alert Moderator