后台怎么取得GridView中ItemTemplate 中的值
2个回答
展开全部
<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();
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();
展开全部
<asp:GridView ID="gridView" runat="server"
OnRowCommand="gridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="输入信息">
<ItemTemplate>
<asp:TextBox ID="tbx" runat="server" TextMode="MultiLine" Width="200px" Height="50px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
string tbx = ((TextBox)gridView.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("tbx")).Text;
}
OnRowCommand="gridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="输入信息">
<ItemTemplate>
<asp:TextBox ID="tbx" runat="server" TextMode="MultiLine" Width="200px" Height="50px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
string tbx = ((TextBox)gridView.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("tbx")).Text;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询