如何从数据网格控件中获取for循环中的数据 [英] How I can get data in a for cycle from datagrid control
问题描述
亲爱的朋友们
我的.aspx页面中有一个DataGrid Web控件。
这个控件有4列,第一列有一个复选框输入。
第二个只有一个显示任何信息的文本
第三列只有文字和数字四列。
请参阅.aspx页面中我的控件代码:
Dear Friends
I Have an DataGrid Web Control in my .aspx page.
This Control have 4 columns the first one have a checkbox input.
the second one have only a text that show any information
the third column have only text and the number four column too.
Please see the code of my control in .aspx page:
<asp:datagrid id="dtgDistribuidores" runat="server" Width="100%" CellSpacing="1" CssClass="datagrid" AutoGenerateColumns="False">
<AlternatingItemStyle CssClass="rowAlt"></AlternatingItemStyle>
<ItemStyle CssClass="row"></ItemStyle>
<HeaderStyle CssClass="header"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="ELEJIR">
<ItemTemplate>
<input type="checkbox" id="cbElejirEmpresa" runat="server" title="Elejir" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="CODIGO_EMPRESA" HeaderText="Código" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="IDENTIFICACION" HeaderText="RUC"></asp:BoundColumn>
<asp:BoundColumn DataField="NOMBRE_EMPRESA" HeaderText="EMPRESA"></asp:BoundColumn>
</Columns>
</asp:datagrid>
我在aspx页面后面有c#代码,我需要处理DataGrid组件中每行的数据
I have the c# code behind the aspx page and I need process the data for each row in the DataGrid component
private void btnGuardar_Click(object sender, System.EventArgs e)
{
/*INSERT YOUR CODE HERE*/
}
我需要你的帮助,请告诉我怎样才能:
1)从for中获取每行的数据循环
2)我想进行在DataGrid Web控件中检查的行我如何做到这一点。
提前致谢
Leonardo Ayala R.
Please I need your help, Please tell me how I can:
1) Get the data from the component for each row in a for cycle
2) I want to precess the rows that are checked in the DataGrid Web control How I can do this.
Thanks in advance
Leonardo Ayala R.
推荐答案
首先,谷歌这些事情兄弟...
First off, google these thing bro...
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
foreach (DataGridViewCell dc in dr.Cells)
{
//dc is each cell, take it from there
}
}
这只是一个搜索。
It was just a search away.
从for循环中的每一行获取组件中的数据
Get the data from the component for each row in a for cycle
回答您的第一个查询,可以通过多种方式完成,例如:在迭代Gridview行集合或使用单元格属性时使用FindControl。
http://forums.asp.net/t/1893452.aspx?loop+through+all+rows+in+a+gridview+and+get+the+contents 一> [ ^ ]
Answering your first query , it can be done multiple ways such as using FindControl while iterating through the Gridview Row Collections or by using cells property.
http://forums.asp.net/t/1893452.aspx?loop+through+all+rows+in+a+gridview+and+get+the+contents[^]
我想进行在DataGrid Web控件中检查的行如何执行此操作
I want to precess the rows that are checked in the DataGrid Web control How I can do this
请参阅以下链接以获取所选行
http://www.aspsnippets.com/Articles/GridView-with-CheckBox-Get-Selected-Rows-in-ASPNet.aspx [ ^ ]
希望这有助于
Refer below link to get the selected rows
http://www.aspsnippets.com/Articles/GridView-with-CheckBox-Get-Selected-Rows-in-ASPNet.aspx[^]
Hope this helps
这篇关于如何从数据网格控件中获取for循环中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!