»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
Code to render a control to HTMLThis code shows you how to render a control datagrid,repeater and other controls to a html.
private void ClearControls(System.Web.UI.Control control)
{
for (int i=control.Controls.Count -1; i>=0; i--)
{
ClearControls(control.Controls[i]);
}
if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
control.Parent.Controls.Add(literal);
try
{
literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control,null);
}
catch
{
}
control.Parent.Controls.Remove(control);
}
else
if (control.GetType().GetProperty("Text") != null)
{
System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control,null);
control.Parent.Controls.Remove(control);
}
}
return;
}
|
private void gethtml(Control dgView,string type,int numofrows)
{
///////create pager
///
int numofpages = 25;
int noofindex = 0;
if(numofrows > numofpages)
{
int div = numofrows / numofpages;
int mod = numofrows % numofpages;
if(mod != 0)
{
div = div + 1;
}
noofindex = div;
}
int g;
string str8="";
string str=" ";
for(g=0;g{
str8 = SF.ToSafeString(g);
if(Request.QueryString["pindex"]!= null)
{
if(str8 == Request.QueryString["pindex"])
{
str8 = "" + str8 + "";
}
}
str += @"" + str8 + " ";
}
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dgView);
dgView.RenderControl(oHtmlTextWriter);
string str1 = oStringWriter.ToString();
st
|
© 2008 dotnetwatch.com -- Privacy policy
|