Click here to Skip to main content
15,905,682 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: GridView bind with dropdown, needed page refresh .. Pin
SimulationofSai10-May-07 9:17
SimulationofSai10-May-07 9:17 
GeneralRe: GridView bind with dropdown, needed page refresh .. Pin
Milw199111-May-07 8:57
Milw199111-May-07 8:57 
Questionhow to access hidden columns in the grid Pin
rama charan10-May-07 5:15
rama charan10-May-07 5:15 
AnswerRe: how to access hidden columns in the grid Pin
SimulationofSai10-May-07 9:26
SimulationofSai10-May-07 9:26 
GeneralRe: how to access hidden columns in the grid Pin
rama charan10-May-07 21:04
rama charan10-May-07 21:04 
QuestionDatagrid Dropdownlist Pin
robw188810-May-07 5:05
robw188810-May-07 5:05 
AnswerRe: Datagrid Dropdownlist Pin
DanB198310-May-07 23:42
DanB198310-May-07 23:42 
GeneralRe: Datagrid Dropdownlist Pin
robw188811-May-07 1:08
robw188811-May-07 1:08 
Hi Dan, thanks for the reply.

Here is my code showing functions to populate the dataset and to get the selected row.

StatusID is the primary key in my access database & thought I'd need to use it to default the value of the dropdownlist to the current value.

Function GetStatus() as DataSet 

	
	Dim DBConn as OleDbConnection
	Dim DBCommand as OleDbDataAdapter
	
			
	DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/Auto_log.mdb") & ";")
	DBCommand = New OleDbDataAdapter("SELECT StatusID, Status from Status ORDER BY Status", DBConn)


	DBCommand.Fill(DS, "Status")
	DBConn.Close()
	
    Return DS
			
	
End Function

    Function GetSelectedIndex(ByVal StatusID As String) As Integer
        'Loop through the DataSet DS
        Dim iLoop As Integer
        Dim DT As DataTable = DS.Tables("Status")
        For iLoop = 0 To DT.Rows.Count - 1
            If StatusID = DT.Rows(iLoop)("StatusID").ToString Then
                Return iLoop
            End If
        Next iLoop
    End Function


I then declare the ddl in my update subroutine as follows

Dim ddlStatus As DropDownList = FindControl("ddlStatusctrl")


and here is the ddl control from my datagrid:

<asp:TemplateColumn>
	<HeaderTemplate>
	Status		
	</HeaderTemplate>
	<ItemTemplate>
	<%# Container.DataItem("Status") %>
	</ItemTemplate>
	<EditItemTemplate>
	<asp:DropDownList id="ddlStatusctrl" runat="server"
	DataTextField="Status"
	DataValueField="StatusID"
	DataSource="<%#	GetStatus() %>"   
	SelectedIndex='<%# GetSelectedIndex(Container.DataItem("StatusID")) %>' />
	</EditItemTemplate>
</asp:TemplateColumn>






Rob

QuestionHow help others through coding in their project and earn money ? Pin
Bijay Bhaskar Deo10-May-07 4:06
Bijay Bhaskar Deo10-May-07 4:06 
AnswerRe: How help others through coding in their project and earn money ? Pin
enjoycrack10-May-07 4:10
enjoycrack10-May-07 4:10 
GeneralRe: Very Urgent Pin
Kurmala10-May-07 3:26
Kurmala10-May-07 3:26 
GeneralRe: Very Urgent Pin
Sathesh Sakthivel10-May-07 3:27
Sathesh Sakthivel10-May-07 3:27 
QuestionVery Urgent Pin
Kurmala10-May-07 3:10
Kurmala10-May-07 3:10 
AnswerRe: Very Urgent Pin
Sathesh Sakthivel10-May-07 3:13
Sathesh Sakthivel10-May-07 3:13 
QuestionRe: Very Urgent Pin
Kurmala10-May-07 3:19
Kurmala10-May-07 3:19 
AnswerRe: Very Urgent Pin
Sathesh Sakthivel10-May-07 3:22
Sathesh Sakthivel10-May-07 3:22 
AnswerRe: Very Urgent Pin
Bijay Bhaskar Deo10-May-07 3:26
Bijay Bhaskar Deo10-May-07 3:26 
QuestionRe: Very Urgent Pin
Kurmala10-May-07 3:50
Kurmala10-May-07 3:50 
AnswerRe: Very Urgent Pin
enjoycrack10-May-07 3:27
enjoycrack10-May-07 3:27 
QuestionRe: Very Urgent Pin
Kurmala10-May-07 3:30
Kurmala10-May-07 3:30 
QuestionRe: Very Urgent Pin
Kurmala10-May-07 3:34
Kurmala10-May-07 3:34 
AnswerRe: Very Urgent Pin
Sathesh Sakthivel10-May-07 3:41
Sathesh Sakthivel10-May-07 3:41 
QuestionRe: Very Urgent Pin
Kurmala10-May-07 3:44
Kurmala10-May-07 3:44 
AnswerRe: Very Urgent Pin
enjoycrack10-May-07 3:46
enjoycrack10-May-07 3:46 
AnswerRe: Very Urgent Pin
Sathesh Sakthivel10-May-07 3:47
Sathesh Sakthivel10-May-07 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.