i have one grid in that i add one button and i set RowCommand event like this
OnRowCommand="gvProject_RowCommand" and the code for button is
when i click the button on page its not generating the event please any one tell me where i am doing mistake
thanks in advance

Kirtan PatelRank #292 · 8.6K reputationPosted Oct 12, 2009, 6:32 AM EDT
mohdazeemuddin ahmed125 reputationPosted Oct 12, 2009, 6:40 AM EDT
{
if (e.CommandName == "SendRequest")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvProject.Rows[index];
lblMessage.Text = "hello";
lblMessage.Visible = true;
}
}
for testing i am displaying some message if it work i will write my logic but the frame work dos not entering into this method its not executing this method
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 12, 2009, 6:55 AM EDT
Code Behind
----------------------------------------------------------------------------
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "SendRequest")
{
Response.Write("Testing Event ");
}
}
HTML Code
-------------------------------
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"> Columns> asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" /> asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" /> asp:TemplateField ShowHeader="False"> ItemTemplate> asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="SendRequest" CommandArgument='' Text="Button" /> ItemTemplate> asp:TemplateField> Columns> asp:GridView>mohdazeemuddin ahmed125 reputationPosted Oct 12, 2009, 7:09 AM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 12, 2009, 7:13 AM EDT
send it in Zip File
[email protected]
Roei BarRank #1,271 · 1.4K reputationPosted Oct 12, 2009, 7:33 AM EDT
its probebly something stupid
Master BillaRank #2,229 · 630 reputationPosted Oct 12, 2009, 8:47 AM EDT
I think something you are missing,
try with this my code
protected void gridviewSRHeaders_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
GridViewRow row = gridviewSRHeaders.Rows[Convert.ToInt32(e.CommandArgument)];
}
}
<asp:GridView ID="gridviewSRHeaders" runat="server" AllowPaging="True" AutoGenerateColumns="False"
OnRowCommand="gridviewSRHeaders_RowCommand">
<asp:ImageButton ID="btnEdit" runat="server" ToolTip="Update" CommandName="Update" CommandArgument="<%# Container.DataItemIndex %>"
/>
GridView>
thank you