c#獲取gridview的值代碼分享
更新時(shí)間:2013年12月12日 09:39:47 作者:
這篇文章主要介紹了C#如何在事件中獲得GridView里面TextBox的值,大家參考使用吧
GridView設(shè)置如下:
復(fù)制代碼 代碼如下:
<asp:GridView ID="GridViewlb" runat="server" AutoGenerateColumns="False" CssClass="tabblue" ShowCellToolTip=" True"
EmptyDataText="暫時(shí)沒有記錄!" 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="編號(hào)" />
<asp:BoundField DataField="type" HeaderText="類型" />
<asp:BoundField DataField="item" HeaderText="項(xiàng)目" ></asp:BoundField>
<asp:BoundField DataField="detail" HeaderText="內(nèi)容" >
<ItemStyle Width="100px" />
<ItemStyle Width="120px" />
</asp:BoundField>
<asp:BoundField DataField="basescore" HeaderText="基本分" />
<asp:BoundField DataField="stdevaluation" HeaderText="評(píng)分標(biāo)準(zhǔn)" />
<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的值:
顯然這里是模板列,可以利用:
復(fù)制代碼 代碼如下:
string str = ((TextBox)(this.GridView1.Rows[行號(hào)].Cells[6].FindControl("textBox1"))).Text.Trim();
如果不是模板列,可以利用
復(fù)制代碼 代碼如下:
string str = this.GridView1.Rows[行號(hào)].Cells[6].Text.Trim();
相關(guān)文章
c#基礎(chǔ)系列之System.String的深入理解
這篇文章主要給大家介紹了關(guān)于c#基礎(chǔ)系列之System.String的深入理解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-09-09C#事件中的兩個(gè)參數(shù)詳解(object sender,EventArgs e)
這篇文章主要介紹了C#事件中的兩個(gè)參數(shù)詳解(object sender,EventArgs e),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09C#實(shí)現(xiàn)一個(gè)控制臺(tái)的點(diǎn)餐系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)一個(gè)控制臺(tái)的點(diǎn)餐系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11C# BinaryReader實(shí)現(xiàn)讀取二進(jìn)制文件
在 C# 以二進(jìn)制形式讀取數(shù)據(jù)時(shí)使用的是 BinaryReader 類。本文介紹了C# BinaryReader實(shí)現(xiàn)讀取二進(jìn)制文件,感興趣的可以了解一下2021-06-06WPF如何自定義ProgressBar滾動(dòng)條樣式
這篇文章主要給大家介紹了關(guān)于WPF如何自定義ProgressBar滾動(dòng)條樣式的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用WPF具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06C#使用Aspose.Cells創(chuàng)建和讀取Excel文件
這篇文章主要為大家詳細(xì)介紹了C#使用Aspose.Cells創(chuàng)建和讀取Excel文件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10