Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Need to Bind Database value to Drop Down List in GridView

Reply
Thread Tools

Need to Bind Database value to Drop Down List in GridView

 
 
bjkaledas
Guest
Posts: n/a
 
      05-14-2007
Hello,

I have the following code:

<asp:TemplateField HeaderText="Ship Date">

<ItemTemplate>



<aspropDownList id="ddlShipDate" Runat="Server"

SelectedValue='<%# GetShipDate(Eval("SHIPDATE")) %>'

AppendDataBoundItems="True" Font-Size="8pt">

<asp:ListItem Value="None">None</asp:ListItem>

<asp:ListItem Value="PROMPT">Prompt</asp:ListItem>

</aspropDownList>

</ItemTemplate>

</asp:TemplateField>



Public Function GetShipDate(ByVal currentshipdate As Object) As String

If currentshipdate Is DBNull.Value And Not currentshipdate = "PROMPT" Then

Return "None"



End If

Return (currentshipdate)

End Function



I need to include the actual value in the drop down list that is stored in
the ShipDate field in the database table.

I need another listitem something like this:

<asp:ListItem Value="Ship"><%# GetShipDate(Eval("SHIPDATE")) %></asp:ListItem>

but this does not work.



I need this because I have selections for the null values and those that
read "PROMPT", but not for other random values that exist. The user would be
able to select "None", "Prompt", or leave it at the date that was stored in
the table.



Thanks!

 
Reply With Quote
 
 
 
 
KyleK
Guest
Posts: n/a
 
      05-17-2007
I prefer to bind the event in the code behind. So on PageLoad bind the
dropdown to GetShipDate and then add Prompt and None list items to the
dropdown.

Hope this helps.
--
Kyle Kelin
..NET Developer
www.dotnetmafia.com


"bjkaledas" wrote:

> Hello,
>
> I have the following code:
>
> <asp:TemplateField HeaderText="Ship Date">
>
> <ItemTemplate>
>
>
>
> <aspropDownList id="ddlShipDate" Runat="Server"
>
> SelectedValue='<%# GetShipDate(Eval("SHIPDATE")) %>'
>
> AppendDataBoundItems="True" Font-Size="8pt">
>
> <asp:ListItem Value="None">None</asp:ListItem>
>
> <asp:ListItem Value="PROMPT">Prompt</asp:ListItem>
>
> </aspropDownList>
>
> </ItemTemplate>
>
> </asp:TemplateField>
>
>
>
> Public Function GetShipDate(ByVal currentshipdate As Object) As String
>
> If currentshipdate Is DBNull.Value And Not currentshipdate = "PROMPT" Then
>
> Return "None"
>
>
>
> End If
>
> Return (currentshipdate)
>
> End Function
>
>
>
> I need to include the actual value in the drop down list that is stored in
> the ShipDate field in the database table.
>
> I need another listitem something like this:
>
> <asp:ListItem Value="Ship"><%# GetShipDate(Eval("SHIPDATE")) %></asp:ListItem>
>
> but this does not work.
>
>
>
> I need this because I have selections for the null values and those that
> read "PROMPT", but not for other random values that exist. The user would be
> able to select "None", "Prompt", or leave it at the date that was stored in
> the table.
>
>
>
> Thanks!
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
binding to current value in a drop down list when populating from a database TB ASP .Net 5 11-02-2005 08:59 PM
How to bind data from database access to drop down list control? Joey Liang via DotNetMonster.com ASP .Net 1 05-13-2005 09:29 AM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments