QUOTE(H3noy @ 10 Jul, 2008 - 08:05 PM)

Hello Expert,
My name Neysha. I'm beginner in ASP.NET
i have a code to show popup like this :
CODE
<asp:GridView AutoGenerateColumns ="False" ID="ViewDetailsAC" runat ="server" CellPadding="3" ForeColor="Black" GridLines="Vertical" Width="894px" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" >
<Columns >
<asp:TemplateField HeaderText="No Asset">
<ItemTemplate >
<asp:LinkButton ID="LinkAsset" Text ="Input" runat ="server" onclick="btnInput_Click" CommandName ="commandInput" CommandArgument ='<%# DataBinder.Eval(Container, "RowIndex") %>' ></asp:LinkButton>
<cc1:ModalPopupExtender ID="LinkAsset_ModalPopupExtender" runat="server" PopupControlID="PanelNoAsset" TargetControlID="LinkAsset" BackgroundCssClass = "modalBackground" >
</cc1:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When i clicked "LinkAsset", i can show a modalpopup and i can input a value of asset in a textbox name "txtAsset", but when i click save, i wanna update table detail in my database, i mean update asset number and status..
in table details i have 3 primary keys,and the problems is i can't read Row Index in gridview when "LinkAsset" was Clicked..Can anyone help me?
In design view add the onrowdatabound attribute to the grid view markup.
Then in code behind implement GridView1_RowDataBound method.
CODE
<asp:GridView ID="GridView1" OnRowDataBound="GridView1_RowDataBound">
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//In here get reference to the button that was clicked and set its command name to
// e.Row.RowIndex.ToString();
Button btn = (Button)e.Row.FindControl("Button1");
btn.ComandName = e.Row.RowIndex.ToString();
//Now in your button's event handler you can retreive the data from a row on the Grid.
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
SomeControlthatHoldsIdToUpdateDB x = (SomeControlthatHoldsIdToUpdateDB)GridView1.Rows[Convert.ToInt32(btn.CommandName)].FindControl("ControlName");
}