Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GURU HELP??? Dropdown List in Datagrid Footer

Reply
Thread Tools

GURU HELP??? Dropdown List in Datagrid Footer

 
 
=?Utf-8?B?VGltOjouLg==?=
Guest
Posts: n/a
 
      09-22-2004
Can some please tell me why this dropdown list isn't getting populated in my
datagrid! I don't get any error the datagrid just doesn't populate. I would
appritiate any examples.

Thanks

...::Inline Code

<FooterTemplate>
<!-- Pull Office Names from Database -->
<aspropDownList id="DDLaddOffice" runat="server"></aspropDownList>
</FooterTemplate>

...::CODEBEHIND

Private Sub populateDDL_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)

'Construct the Database Connection
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("SelectOffice", Myconn)


If e.Item.ItemType = ListItemType.Footer Then


cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim add_Office As DropDownList

'Payment Method Dll - create, fill and preselect

add_Office = CType(e.Item.FindControl("DDLaddOffice"),
DropDownList)
add_Office.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
add_Office.DataBind()
add_Office.Items.Insert(0, "Select One")
add_Office.Items.FindByText("Select One").Value = 0 'insert
don't create a value, but we need a value during defaults
add_Office.SelectedIndex = 0
End If

End Sub
 
Reply With Quote
 
 
 
 
GrantMagic
Guest
Posts: n/a
 
      09-22-2004
Have you set the datagrid's OnItemDataBound:
i.e. OnItemDataBound = "populateDDL_ItemDataBound"

If that is not that case,
try populating the datalist manually in the databound command i.e. not using
a database, just add_Office.Items.Insert(0, "Select One").
This will determine if it is the binding that is the problem, or something
with your method.
But it looks fine to me

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:03F2C1B7-C56C-497C-A812-...
> Can some please tell me why this dropdown list isn't getting populated in
> my
> datagrid! I don't get any error the datagrid just doesn't populate. I
> would
> appritiate any examples.
>
> Thanks
>
> ..::Inline Code
>
> <FooterTemplate>
> <!-- Pull Office Names from Database -->
> <aspropDownList id="DDLaddOffice" runat="server"></aspropDownList>
> </FooterTemplate>
>
> ..::CODEBEHIND
>
> Private Sub populateDDL_ItemDataBound(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs)
>
> 'Construct the Database Connection
> Dim Myconn As New
> SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
> Dim cmd As New SqlCommand("SelectOffice", Myconn)
>
>
> If e.Item.ItemType = ListItemType.Footer Then
>
>
> cmd.CommandType = CommandType.StoredProcedure
>
> Myconn.Open()
>
> Dim add_Office As DropDownList
>
> 'Payment Method Dll - create, fill and preselect
>
> add_Office = CType(e.Item.FindControl("DDLaddOffice"),
> DropDownList)
> add_Office.DataSource =
> cmd.ExecuteReader(CommandBehavior.CloseConnection)
> add_Office.DataBind()
> add_Office.Items.Insert(0, "Select One")
> add_Office.Items.FindByText("Select One").Value = 0 'insert
> don't create a value, but we need a value during defaults
> add_Office.SelectedIndex = 0
> End If
>
> End Sub



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGltOjouLg==?=
Guest
Posts: n/a
 
      09-23-2004
Thanks! You where correct about the OnItemDataBound

Kind Regards

Alan

"GrantMagic" wrote:

> Have you set the datagrid's OnItemDataBound:
> i.e. OnItemDataBound = "populateDDL_ItemDataBound"
>
> If that is not that case,
> try populating the datalist manually in the databound command i.e. not using
> a database, just add_Office.Items.Insert(0, "Select One").
> This will determine if it is the binding that is the problem, or something
> with your method.
> But it looks fine to me
>
> "Tim::.." <myatix_at_hotmail.com> wrote in message
> news:03F2C1B7-C56C-497C-A812-...
> > Can some please tell me why this dropdown list isn't getting populated in
> > my
> > datagrid! I don't get any error the datagrid just doesn't populate. I
> > would
> > appritiate any examples.
> >
> > Thanks
> >
> > ..::Inline Code
> >
> > <FooterTemplate>
> > <!-- Pull Office Names from Database -->
> > <aspropDownList id="DDLaddOffice" runat="server"></aspropDownList>
> > </FooterTemplate>
> >
> > ..::CODEBEHIND
> >
> > Private Sub populateDDL_ItemDataBound(ByVal sender As Object, ByVal e As
> > System.Web.UI.WebControls.DataGridItemEventArgs)
> >
> > 'Construct the Database Connection
> > Dim Myconn As New
> > SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
> > Dim cmd As New SqlCommand("SelectOffice", Myconn)
> >
> >
> > If e.Item.ItemType = ListItemType.Footer Then
> >
> >
> > cmd.CommandType = CommandType.StoredProcedure
> >
> > Myconn.Open()
> >
> > Dim add_Office As DropDownList
> >
> > 'Payment Method Dll - create, fill and preselect
> >
> > add_Office = CType(e.Item.FindControl("DDLaddOffice"),
> > DropDownList)
> > add_Office.DataSource =
> > cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > add_Office.DataBind()
> > add_Office.Items.Insert(0, "Select One")
> > add_Office.Items.FindByText("Select One").Value = 0 'insert
> > don't create a value, but we need a value during defaults
> > add_Office.SelectedIndex = 0
> > End If
> >
> > End Sub

>
>
>

 
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
IT Job Guru - Certification Guru Rohit A+ Certification 0 08-13-2008 07:31 PM
Any way to reorder how a datagrid is drawn (header/footer/items vs.header/items/footer)? Henrik ASP .Net Datagrid Control 1 07-06-2006 12:23 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
Dropdown in footer template of datagrid Edward Bills ASP .Net Datagrid Control 5 07-22-2004 02:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57