I am back after long time. I have a requirement to display a grid using sript call back. I search on net and found that all solutions suggest that generate XML file and pass it to java script. Itrate through XML file and generate "
Javascript Code
<script language="javascript" type="text/javascript">
function GenerateGrid(object)
{
var message = document.getElementById("ddlEmployeeName").value ;
var context = '';
<%= strCallback %>
return false;
}
function GenerateGridData(message,context)
{
// Here lblGrid is name of my lable.
document.getElementById("lblGrid").innerHTML = message;
}
script>
Server Side Code
Here I have removed extra code.
public void RaiseCallbackEvent(string eventArgument)
{
// Create new GridView and Bind it
GridView gvGridView = new GridView ();
gvGridView.DataSource = ds;
gvGridView.DataBind();
// Get string writer and HTML writer
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter ht = new HtmlTextWriter(sw);
// This will generate HTML
gvGridView.RenderControl(ht);
strData = sw .ToString();
}
public string GetCallbackResult()
{
// return value to javascript
return strData;
}
How simple!!! I have displayed the grid without XML file and iteration logic of javascript. Then I remember a good quote of my friend, the rule of "KIS (Keep It Simple)". I am working on paging and editing of grid with script callback and will soon post the blog.
Bye and do happy programming.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment