create table BoardMaster( BoardID int identity(1,1), BoardName varchar(50), CreateDate varchar(50), status bit, CreatedBy int )
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "editBoard") { int index = Convert.ToInt32(e.CommandArgument); // Error - System.FormateException: Input string was not in a correct format. GridViewRow row = GridView1.Rows[index]; txtBid.Text = row.Cells[1].Text; txtBname.Text = row.Cells[2].Text; txtCreatedate.Text = row.Cells[3].Text; int st = 1; if (row.Cells[4].Text == st.ToString()) { cbStatus.Checked = true; } else cbStatus.Checked = false; txtCreateBy.Text = row.Cells[5].Text; } }
asp:GridView ID="GridView1" ShowFooter="True" AutoGenerateColumns="False" runat="server" onrowcommand="GridView1_RowCommand1" > <Columns> <asp:BoundField DataField="BoardID" HeaderText="BoardID" ReadOnly="True" SortExpression="BoardID" /> <asp:BoundField DataField="BoardName" HeaderText="Board Name" SortExpression="BoardName" /> <asp:BoundField DataField="CreateDate" HeaderText="Created Date" SortExpression="CreateDate" /> <asp:CheckBoxField DataField="status" HeaderText="Status" SortExpression="status"/> <asp:BoundField DataField="CreatedBy" HeaderText="Created By" SortExpression="CreatedBy" /> <asp:TemplateField HeaderText="Eidt"> <ItemTemplate> <asp:Button ID="editBoard" CommandName="editBoard" runat="server" Text="Edit"></asp:Button> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
//GridViewRow row = GridView1.Rows[index]; GridViewRow row = (GridViewRow)GridView1.NamingContainer;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)