如何将gridview选定行传输到文本框和复选框[英] how transfer gridview selected row to textbox and check box

本文是小编为大家收集整理的关于如何将gridview选定行传输到文本框和复选框的处理方法,想解了如何将gridview选定行传输到文本框和复选框的问题怎么解决?如何将gridview选定行传输到文本框和复选框问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

创建  BoardMaster(BoardID int identity(1,1),BoardName varchar(50),CreateDate varchar(50),状态 ,CreatedBy int)

C#代码:
protected void GridView1_RowCommand1(对象 发送者,GridViewCommandEventArgs e){if (e.CommandName == "editBoard"){int index = Convert.ToInt32(e.CommandArgument);// 错误 - System.FormateException:输入字符串的格式不正确.GridViewRow 行 = 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;}其他cbStatus.Checked = false;txtCreateBy.Text = row.Cells[5].Text;}}

ASP代码:
asp:GridView ID="GridView1" ShowFooter="True" AutoGenerateColumns="False"runat="server" onrowcommand="GridView1_RowCommand1" ><><asp:BoundField  DataField="BoardID" HeaderText="BoardID"        只读="True" SortExpression="BoardID" /><asp:BoundField  DataField="BoardName" HeaderText="Board Name" SortExpression="BoardName" /><asp:BoundField  DataField="CreateDate" HeaderText="创建日期"        SortExpression="创建日期" /><asp:CheckBoxField DataField="status" HeaderText="状态" SortExpression="状态"/><asp:BoundField  DataField="CreatedBy" HeaderText="创建者"        SortExpression="CreatedBy" /><asp:TemplateField HeaderText="Eidt"><ItemTemplate><asp:Button ID="editBoard" CommandName="editBoard" runat="服务器" 文本="编辑"></asp:Button></ItemTemplate></asp:TemplateField></Columns></asp:GridView>

推荐答案

你好,

试试这个……

//GridViewRow row = GridView1.Rows[index];GridViewRow 行 = (GridViewRow)GridView1.NamingContainer;


如果有帮助,请投票...

问候,

本文地址:https://www.itbaoku.cn/post/1355848.html