本文介绍了获取所有单元格的值(Gridview)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#,asp.net,服务器2005和Visual Studio 2005

我的gridview设计看起来像这样:


FIRST_COLUMN | SECOND_COLUMN | THIRD_COLUMN | FOURTH_COLUMN | FIFTH_COLUMN |
------------ ------------- ------------ ------------- ------------
TEXTBOX1 |下拉列表| TEXTBOX2 | TEXTBOX3 | TEXTBOX4 |

Gridview包含一行5列.

现在如何在不使用任何事件的情况下获取每一列的值...

单击按钮时我必须获取值..

请帮我..

问候
karan

I''m using C#,asp.net,server 2005 and visual studio 2005

my gridview design looks like this:


FIRST_COLUMN| SECOND_COLUMN| THIRD_COLUMN| FOURTH_COLUMN| FIFTH_COLUMN|
------------ ------------- ------------ ------------- ------------
TEXTBOX1 | DROPDOWNLIST | TEXTBOX2 | TEXTBOX3 | TEXTBOX4|

Gridview contains one row and 5 columns.

now how to get the value of each column without using any of the event...

i have to get the value when the button is clicked..

plz help me..

regards
karan

推荐答案

protected void Button1_Click(object sender, EventArgs e)
{
    // Iterates through the rows of the GridView control
    foreach (GridViewRow row in GridView1.Rows)
    {
        // Selects the text from the TextBox
        // which is inside the GridView control
        string textBoxText = _
          ((TextBox)row.FindControl("TextBox1")).Text;

        // Selects the text from the DropDownList
        // which is inside the GridView control
        string dropDownListText = ((DropDownList)
           row.FindControl("DropDownList1")).SelectedItem.Value;

    }
}


这篇关于获取所有单元格的值(Gridview)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:19