Last post Jun 28, 2013 03:12 AM by mr.rahulmaurya
Jun 19, 2013 06:20 AM|BoxheadMonkey|LINK
I have a gridview which contains a custom control which takes some text and turns it into a link which opens a popup window. I have a button which deletes a row from the gridview and hides the deleted row (postback). When i click this button, the column
containing the text for the custom control disappears. I have set enable view state on both the custom control and the hyperlink within it:
Custom control initiator:
<wts:PopUp ID="ucActionBy" runat="server" PopUpTypeEnum="MySite" CollarNumber='<%# Eval("ActionBy") %>' EnableViewState="true" />
Custom control ascx:
<asp:HyperLink runat="server" ID="hypPopUp" EnableViewState="true" />
Where am i going wrong?
Jun 19, 2013 06:46 AM|mr.rahulmaurya|LINK
Load grid view on page Load event.
Jun 19, 2013 08:41 AM|BoxheadMonkey|LINK
Sorry not sure what you mean or how that will help?
Jun 20, 2013 07:27 AM|mr.rahulmaurya|LINK
when a postback button click then page load again and load envent fired.
If grid view not load on the event then grid view loss the view state as well as cutom control.
Can post the server side code?.
Jun 24, 2013 09:05 AM|BoxheadMonkey|LINK
The gridview has EnableViewState set to true - all other columns retain their information - it is only the user control which doesn't. Here is the code which the button in the gridview row calls:
protected void ibMarkAuditedPending_Click(object sender, ImageClickEventArgs e)
ImageButton btnMarkAudit = (ImageButton)sender;
//Get the Row from the ImageButton's parent DataControlFieldCell, who's parent is GridRowView.
using (GridViewRow gvr1 = (GridViewRow)btnMarkAudit.Parent.Parent)
int queryOutcome = Audit.Update((string)gvResults.DataKeys[gvr1.RowIndex].Values["RecordID"]);
if (queryOutcome > 0)
//hide the row set to pending and reduce the count.
gvResults.Rows[gvr1.RowIndex].Visible = false;
lblGridHeadingResults.Text = (int.Parse(lblGridHeadingResults.Text)-1).ToString();
//odsAudit.SelectMethod = "GetAudit";
//odsAudit.TypeName = "Namespace.Audit";
//odsAudit.SelectParameters["pending"].DefaultValue = "False";
lblMessage.Text = "Batch failed to mark as Pending - if this problem persists, please contact IST Service Desk";
You will see that originally i did a call back to the db to get the records again. the reason for the change was that this returns a random set of 10 records - if i run it again it returns a new random set - this was not ther required action. the users
wants 10 random records which they can then work with without loading a different random set severy time the buttn is pressed. To solve this I just set the row to hide - as seen above!
Jun 28, 2013 03:12 AM|mr.rahulmaurya|LINK
try to load gridview on Pageinit.