pratikshahse
asked on
Dropdown in gridview ASP.NET,VB.NET
I have a gridview in one of my aspx pages in which I want one column to be dropdown and one other to be a check box and rest to be text boxes. So when the gridview loads all the columns are read only but when the user hits edit button first column needs to be a dropdown with the the values in it being populated from a table in the database. second column needs to be checkbox. rest as textboxes.
Here is how I have created my gridview in the aspx.
<asp:GridView ID="GridView1" AutoGenerateColumns="true" AllowPaging="true" AllowSorting="true"
onrowdeleting="GridView1_R owDeleting " onrowediting="GridView1_Ro wEditing"
runat="server" AutoGenerateDeleteButton=" True" AutoGenerateEditButton="Tr ue"
Width="317px">
<PagerSettings Position="Top" Mode="NumericFirstLast" />
<PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" BackColor="#ECF0FC" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="#284E98" ForeColor="White" Font-Bold="True" />
<EditRowStyle Wrap="False" />
<AlternatingRowStyle BackColor="#F6F1D4" BorderColor="Black" />
</asp:GridView>
Code Behind to populate the gridview:
Dim cmdList As DbCommand = m_database.GetStoredProcCo mmand("sto reproc_nam e")
Dim listDS As DataSet = m_database.ExecuteDataSet( cmdList)
Dim iNoOfRowsReturend As Integer = listDS.Tables(0).Rows.Coun t
ShowSearchMessage(iNoOfRow sReturend)
GridView1.DataSource = listDS
GridView1.DataBind()
Can someone please help me with this.
Thanks
Here is how I have created my gridview in the aspx.
<asp:GridView ID="GridView1" AutoGenerateColumns="true"
onrowdeleting="GridView1_R
runat="server" AutoGenerateDeleteButton="
Width="317px">
<PagerSettings Position="Top" Mode="NumericFirstLast" />
<PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" BackColor="#ECF0FC" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="#284E98" ForeColor="White" Font-Bold="True" />
<EditRowStyle Wrap="False" />
<AlternatingRowStyle BackColor="#F6F1D4" BorderColor="Black" />
</asp:GridView>
Code Behind to populate the gridview:
Dim cmdList As DbCommand = m_database.GetStoredProcCo
Dim listDS As DataSet = m_database.ExecuteDataSet(
Dim iNoOfRowsReturend As Integer = listDS.Tables(0).Rows.Coun
ShowSearchMessage(iNoOfRow
GridView1.DataSource = listDS
GridView1.DataBind()
Can someone please help me with this.
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.