|
How to bind data to a gridview located in the footer row?
|
|
|
|
|
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = //your bind data
}
}
|
|
|
|
|
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList objDDL=new DropDownList();
objDDL.TextField="DisplayFieldName";
objDDL.ValueField="ValueFieldName";
objDDL.datasource="yourdatasoruce" ;
objDDL.DataBind();
e.Row.Cells[0].Controls.Add(objDDL);
}
}
Hope this helps!
|
|
|
|
|
protected void gvMandal_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlAssembly = (DropDownList)gvMandal.FooterRow.FindControl("ddlAssembly");
DataView dvAssembly = objGeneral.GetAssemblyNames(ddlDistrict.SelectedValue.ToString());
ddlAssembly.DataSource = dvAssembly;
ddlAssembly.DataTextField = "sAssemblyName";
ddlAssembly.DataValueField = "nAssemblyID";
ddlAssembly.DataBind();
}
}
I used the code like this
It is showing the error--> Object reference not set to an instance of an object.
|
|
|
|
|
Which line is giving error?
Check if "dvAssembly" is null, if so fill it first with data.
|
|
|
|
|
there is error at the line where we find the dropdownlist
|
|
|
|
|
DropDownList ddlAssembly = (DropDownList)e.Row.FindControl("ddlAssembly");
try this.
|
|
|
|
|
|
Great
My pleasure!!
|
|
|
|
|
4anusha4 wrote: DropDownList ddlAssembly = (DropDownList)gvMandal.FooterRow.FindControl("ddlAssembly");
is this the line where the error is generated....
|
|
|
|
|
|
How can I initiate from AspPage2.aspx.cs the other project page AspPage1.aspx.cs to post-back(reload) itself?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: How can I initiate from AspPage2.aspx.cs the other project page AspPage1.aspx.cs to post-back(reload) itself?
Can you explain me the scenario ? If you are in Page1 you can can reload the page2 by simple redirecting. I think your requirement is some think different. Can you please explain ?
Thanks !
|
|
|
|
|
|
Chesnokov Yuriy wrote: How can I initiate from AspPage2.aspx.cs
Means you want to postback from CodeBehind... This is weird.
Are you looking for Server.Execute ?? So that you could get the response of another page from code behind.??
|
|
|
|
|
I've got 2 pages that are opened. In the second page I do some modifications to Session object, then I need to reload first page so that changes would appear in it.
The 2 pages uses the Session object and simply the first one needs to be notified after the changes done from the second one.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: I've got 2 pages that are opened. In the second page I do some modifications to Session object, then I need to reload first page so that changes would appear in it.
So, you are opening two different page in two different window/ Tab . And you want if you change the automatically on different page. I don't think so its possible unless you Refresh the page.
Because all the session operation performing on server side and the first page has already rendered on client side.
You can do one think, make the Page 1 as autorefresh for some interval. But that is not a good idea .
What is your business requirement ?
|
|
|
|
|
I've got main page, Page1.
The Page2 is opened with javascript window.open() attributed in some Page1 button control.
So I need to refresh Page1 from Page2
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: I've got main page, Page1.
The Page2 is opened with javascript window.open() attributed in some Page1 button control.
So I need to refresh Page1 from Page2
Ohhh... Man... Did you mention it earlier... that your Page 2 is popup
Or May be I missed it out.
use,
window.opener.RefereshPresentPage();
|
|
|
|
|
Yes, sorry, Page2 is a popup opened with window.open();
How should I call window.opener.RefreshPresentPage()?
There is a button click handler, where should I paste it?
Чесноков
|
|
|
|
|
|
- On Second page if changes done then set any flag in session.
- On First page poll the flag session periodically via javascript, if flag session set then submit the page throught javascript and perform operation accordingly.
|
|
|
|
|
but that will take some additional java script over head?
Чесноков
|
|
|
|
|
Yes you are right. I think it is a better.
|
|
|
|
|
Oh.. Is the second page is opening in a new window.
If so, just place a Javascript in the response.
this.ClientScript.RegisterStartupScript(typeof(Page), "myscript", "<script>window.opener.document.form[0].submit();</script>");
Or just
this.ClientScript.RegisterStartupScript(typeof(Page), "myscript", "<script>window.opener.location.href = "page.aspx";</script>");
Where page.aspx is the location of the other page.
Hope it works. I didnt tried it.
|
|
|
|