hi,
in vs2005, i have a control of gridview and dropdown. in dropdown list have a item of table header which i configured in gridview.
In Dropdown box, i selected one header means , it select the gridview particular column
here the code i try,
aspx
c#
thanks,
murugavel
in vs2005, i have a control of gridview and dropdown. in dropdown list have a item of table header which i configured in gridview.
In Dropdown box, i selected one header means , it select the gridview particular column
here the code i try,
aspx
Code:
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
DataSourceID="SqlDataSource1" PageSize="5">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT * FROM [Current Product List]"></asp:SqlDataSource>
</div>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
Code:
protected void Page_Load(object sender, EventArgs e)
{
foreach (TableCell header in GridView1.HeaderRow.Cells)
{
DropDownList1.Items.Add(header.Text);
}
label1.Text = DropDownList1.Items.Count.ToString();
a = DropDownList1.Items.Count.ToString();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
int dd1=(GridView1.HeaderRow.FindControl("DropDowmList1"), DropDownList);
Label1.Text = DropDownList1.Items.Count.ToString();
Label1.Text = DropDownList1.SelectedIndex.ToString();
//DropDownList1.SelectedItem.Value=
}
murugavel
Comment