here is my code. Please help
Dim TRDDLds As DataSet = New DataSet()
Function TrainerList() As DataSet
Dim sqlStr As String = "SELECT left(namelast,8)+' ,'+ left(namefirst,3) as contname FROM tbltrainers"
Dim objTRAdapter As SqlDataAdapter = New SqlDataAdapter(sqlStr, objConn)
TRDDLds.Clear()
objTRAdapter.Fill(TRDDLds, "tbltrainers")
Return TRDDLds
End Function
Then in the html for datagrid
<EditItemTemplate>
<TABLE border="0">
<TR>
<TD align="left"><B style="FONT-SIZE: 10pt; OVERFLOW: hidden">Trainer</B></TD>
<TD>
<asp:dropdownlist id="trainers1" Width ="85" runat="server" Font-Size="10pt" DataSource="<%#trainerlist%>" DataTextField="contname" datavaluefield="contname">
</asp:dropdownlist></TD>
</TR>
<TR>
<TD align="left"><B style="FONT-SIZE: 10pt">Client</B></TD>
<TD>
<asp:DropDownList id=clients1 Font-Size="10pt" Width ="85" DataSource="<%#clientlist%>" DataTextField="contname" DataValueField="contname" Runat="server">
</asp:DropDownList></TD>
</TR>
</TABLE>
</EditItemTemplate>
Thanks
RaifWhen you click edit in your grid you must be able to get somthing the is equal to the value or text of you ddl you want to set. Example, you hit edit, you then need to get a value from the row selected. Lets say you setup a hidden field in the dg that contains the ddl value. You get that value then loop through the ddl and when you find the Item[i].value that is equal to your ddl value you set your selected index to i.
if this is of no help, please post the funciton you have assigned to your edit button.
This article does a lot with dropdownlists in a datagrid.
0 comments:
Post a Comment