SelectedIndexChanged Event of GridView? URGENT!

Posted by .Netlearner under ASP.NET on 8/22/2012 | Points: 10 | Views : 16060 | Status : [Member] | Replies : 15
A having a grid which fetches data from the database dynamically.The Code is as follows,

<asp:GridView ID="gvdesig" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvdesig_RowDataBound"
CellPadding="3" onrowcommand="gvdesig_RowCommand" CssClass="GridViewStyle" Width="90%" Height="180px"
OnSorting="gvdesig_Sorting" OnPageIndexChanging="gvdesig_PageIndexChanging" OnSelectedIndexChanged="gvdesig_OnSelectedIndexChanged">
<Columns>
<asp:BoundField DataField="DesignationID" HeaderText="ID" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Designation" HeaderText="Name" ItemStyle-Width="200px" ItemStyle-HorizontalAlign="Center" />

<asp:TemplateField HeaderText="Select" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="btnselect" runat="server" CommandName="select" Text="select" CausesValidation="false" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>


 protected void gvdesig_OnSelectedIndexChanged(object sender, EventArgs e)
{

txtdesig.Text = gvdesig.SelectedRow.Cells[1].Text;
lblDesig.ToolTip = gvdesig.SelectedRow.Cells[0].Text;
ddldept.SelectedItem.Text = gvdesig.SelectedRow.Cells[2].Text;

}


At first while executing i got the following error when the grid row is selected,

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


I added EnableEventValidation="false" in my page directive,now it does'nt throw error but still the SelectedIndexChanged Event is not firing ? Its urgent Please Guide me i dont know where i am wrong. Thanks in advance




Responses

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
if (!IsPostBack)
{
gridviewbindata();
}

and validaterequet=False

tryit.................

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
is gridviewbinddata(); a user defined function?

where i have to add validaterequest=false;

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
i added validaterequest=false in my page directive yet its not working

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rambabu123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
when ever u bind data to gridview That method keep it with in the
if (!IsPostBack)
{

}

I think it is useful for u

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
yeah i have already used thanks for your post but my selectedindex changed event of the grid is not firing how can i solve that

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
first fire the gridviewrowediting event

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
no Am not going to edit the content of the gridview,i just want to display the content of the grid row which is clicked in the server controls

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
but u row click in compulsary row editing event fire it
just implemtning the method

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
now i added that too but still its not working

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
row updated and row updating event fire it

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rambabu123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
Fire RowUpdating Event in gridview

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
i added both updated and updating event still its not working can anyone please help with this

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
command name is used complusary used row command evevnt
protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "select")
{
}
if (e.CommandName == "Edit")
{
}
if (e.CommandName == "Delete")
{

}
}

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
problem solved or not

Mahendra
91-9908699686

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 8/23/2012 [Member] Starter | Points: 25

Up
0
Down
No the problem is not solved

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response