手机
当前位置:查字典教程网 >编程开发 >C#教程 >c#获取gridview的值代码分享
c#获取gridview的值代码分享
摘要:GridView设置如下:复制代码代码如下:获得GridView中TextBox的值:显然这里是模板列,可以利用:复制代码代码如下:stri...

GridView设置如下:

复制代码 代码如下:

<asp:GridView ID="GridViewlb" runat="server" AutoGenerateColumns="False" CssClass="tabblue" ShowCellToolTip=" True"

EmptyDataText="暂时没有记录!" Width="100%" Height="100%" AllowPaging="True" OnPageIndexChanging="GridViewlb_PageIndexChanging"

DataKeyNames="id" PageSize="26" OnRowCreated="GridViewlb_RowCreated" OnRowDataBound="GridViewlb_RowDataBound"

AllowSorting="True">

<Columns >

<asp:BoundField DataField="id" HeaderText="编号" />

<asp:BoundField DataField="type" HeaderText="类型" />

<asp:BoundField DataField="item" HeaderText="项目" ></asp:BoundField>

<asp:BoundField DataField="detail" HeaderText="内容" >

<ItemStyle Width="100px" />

<ItemStyle Width="120px" />

</asp:BoundField>

<asp:BoundField DataField="basescore" HeaderText="基本分" />

<asp:BoundField DataField="stdevaluation" HeaderText="评分标准" />

<asp:TemplateField HeaderText="打分" >

<ItemTemplate>

<asp:TextBox id="textbox1" runat="server" Text="" Width="80%" Height="24px"></asp:TextBox>

</ItemTemplate>

<ItemStyle Width="50px" />

</asp:TemplateField>

</Columns>

</asp:GridView>

获得GridView中TextBox的值:

显然这里是模板列,可以利用:

复制代码 代码如下:

string str = ((TextBox)(this.GridView1.Rows[行号].Cells[6].FindControl("textBox1"))).Text.Trim();

如果不是模板列,可以利用

复制代码 代码如下:

string str = this.GridView1.Rows[行号].Cells[6].Text.Trim();

【c#获取gridview的值代码分享】相关文章:

.net C# 实现任意List的笛卡尔乘积算法代码

C#中实现网段扫描的代码

c# winform读取xml文件创建菜单的代码

c# 接口interface基础入门小例子

获取wince mac地址与IP地址解决方案

用C#写的ADSL拨号程序的代码示例

c#获取本机的IP地址的代码

C# Linq读取XML文件的实例

使用C#实现在屏幕上画图效果的代码实例

c# 获取CookieContainer的所有cookies函数代码

精品推荐
分类导航