Microsoft
Software
Hardware
Network
Question : Gridview Button not firing on first click
This works but only on the 2nd click of the gridview button. Following is the code I have used. Any help is appreciated.
I have constructed a gridview
<asp:GridView ID="gvAction" runat="server"
AutoGenerateColumns="False
"
SkinID="GridViewCTELNopagi
ng"
onrowdatabound = "gvAction_RowDataBound" >
with a button in a template field.
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:Button ID="btnActionGridSearch" runat="server" CommandName="EditAction"
Text="Edit" OnClick = "btnActionGridSearch_Click
" />
</ItemTemplate>
</asp:TemplateField>
In code behind:
rowdatabound:
protected void gvAction_RowDataBound(obje
ct sender, GridViewRowEventArgs e)
{
GridView gv = (GridView)sender;
RowCount = e.Row.RowIndex;
if (e.Row.RowType == DataControlRowType.DataRow
)
{
e.Row.Style["cursor"] = "hand";
btn = (Button)e.Row.FindControl(
"btnAction
GridSearch
");
btn.Attributes.Add("rowNum
ber", RowCount.ToString());
btn.ID = RowCount.ToString();
e.Row.Cells[1].Style.Add("
display", "none");
}
}
button click:
protected void btnActionGridSearch_Click(
object sender, EventArgs e)
{
//Go to hidden panel to display the Followups specific to this opportunity
Button btn = (Button)sender;
string it = btn.Attributes["rowNumber"
].ToString
();
int TheRow = Convert.ToInt16(it);
string ActionID = gvAction.Rows[TheRow].Cell
s[1].Text;
DataTable dtActionItems = dalOpportunityDetail.GetAc
tionByID(A
ctionID);
txtFUSummary.Text = dtActionItems.Rows[0]["Sum
mary"].ToS
tring();
txtMemo.Text = dtActionItems.Rows[0]["Mem
o"].ToStri
ng();
string type = dtActionItems.Rows[0]["Typ
e"].ToStri
ng();
if (dtActionItems.Rows[0]["is
FollowupCl
osed"].ToS
tring() == "-1")
{
rbFuOpen.Checked = true;
rbFuClosed.Checked = false;
}
else
{
rbFuOpen.Checked = false;
rbFuClosed.Checked = true;
}
pnFollowups.Visible = false;
pnFollowupDetail.Visible = true;
}
Answer : Gridview Button not firing on first click
- Why you need this line of code: btn.ID = RowCount.ToString(); ?
- Please post Page_Load function so i can have more informations.
Random Solutions
flash drive manufacurer
existing gift voucher system? - asp.net
How do I delete a file from a folder (uploads directory) when I delete its reference in the database?
Cisco 1310g Wireless Bridge, Fastethernet Hardware Status Down
Quickbooks 2010 QB crashes when trying to print to network printer
After moving mailbox to Exchange 2007 lost all Outlook rules
DNS Problem on Adtran Netvanta 2100
Combofix Log - Analysis Assistance Request
PHP: Decode Modified Base64
How does the pointers of an inode's data block relattes to the logical block address of a SCSI device?