0

我有一个网格视图,其中包含三个字段。第一个是数据绑定字段,第二个是包含文本框控件的模板字段,第三个是包含 FileUpload 控件的模板字段。

我想在文件上传控件完成文件上传操作时禁用网格视图行。

我的网格绑定代码是:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


public partial class gr4 : System.Web.UI.Page
{
    SqlConnection cn;
    SqlCommand cmd;
    SqlDataAdapter da;
    DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    cn = new SqlConnection("Data Source=AMIR-PC\\MOHEMMAD;Initial Catalog=CRM_InvestPlus;Integrated Security=True");
    string query = "Select Capacity from Dealer_License_Capacity where ID='D00001' and Software_ID='001' and Version_ID='1'";
    cn.Open();
    cmd = new SqlCommand(query,cn);
    da = new SqlDataAdapter(cmd);
    ds = new DataSet();
    da.Fill(ds);
    cn.Close();


    string query1 = "select  Price from Version_Master where Software_ID='001' and Version_ID='1'";
    cn.Open();
    cmd = new SqlCommand(query1, cn);
    da = new SqlDataAdapter(cmd);
    DataSet ds1 = new DataSet();
    da.Fill(ds1);
    cn.Close();


    string query2 = "select Software_Name from Software_Master where Software_ID='001'";
    cn.Open();
    cmd = new SqlCommand(query2, cn);
    da = new SqlDataAdapter(cmd);
    DataSet ds2 = new DataSet();
    da.Fill(ds2);
    cn.Close();

    DataTable dt = new DataTable();
   // dt.Columns.Add("Name", typeof(string));
    dt.Columns.Add("Software_Name", typeof(string));
    dt.Columns.Add("Price", typeof(string));

    int count = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());

    for (int i = 0; i < count; i++)
    {
        DataRow dr = dt.NewRow();
     //   dr["Name"] = "aaa";
        dr["Software_Name"] = ds2.Tables[0].Rows[0][0].ToString();
        dr["Price"] = ds1.Tables[0].Rows[0][0].ToString();

        dt.Rows.Add(dr);
        if (i == 0)

            Response.Write(dr["Price"]);

    }

    GridView1.DataSource = dt;
    GridView1.DataBind();

    //GridView1.SelectedRow.Enabled = false;


  }
}

网格的源文件是:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
    <Columns>

        <asp:BoundField DataField="Software_Name" />
        <asp:TemplateField>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>


        <asp:TemplateField>
            <ItemTemplate>
                <asp:FileUpload ID="FileUpload1" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>


    </Columns>
    </asp:GridView>

数据是完美有界的,但我想在文件上传控件完成操作后禁用选定的gridview行。

请帮忙

提前致谢。

4

1 回答 1

0
protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
               e.Row.Enabled=false;//Check on the condition that uploaded is completed            
        }
    }
于 2013-02-11T08:25:03.917 回答