DataGrid Footer DropDownList OnSelectedIndexChanged

ASP.NET

    Next

  • 1. AutoGenerateEditButton=true
    (I'm sorry if this is the wrong place for a GridView Question but I don't know a forum as good as this one) My Q is: Is there any way to AutoGenerate the edit button and have it show an image instead of the text link style? I want to have an image with an onmouseover image so it lights up. Thanks a lot Justin Dutoit
  • 2. Disable ButtonColumn inside DataGrid through logic
    What I am looking to do is disable a column of ButtonColumn type insid my DataGrid when another column of ButtonColumn types is pressed. Fo instance, I have a button in my first column of the DataGrid that I a using to select my row and do a little extra logic. I also have button in the last column of the DataGrid that I am going to use to d some other logic that will display a hidden panel that has a messag with an OK and Cancel buttons asking them for confirmation to delet the row. So, what I want to do is, when you click the 'Delete' button, in m logic where I am un-hiding the panel and its controls, I want t disable the 'Select' button in the first column of the DataGrid for al rows. I currently have it working where I can 'hide' the ButtonColumn in th first column of my DataGrid, by using the following code, but I reall want to leave it visible, but just 'disabled'. Does anybody know of way to do this? dgCashReports.Columns[0].visible = false; // this hides the entir column of ButtonColumns Thanks, Stephe

DataGrid Footer DropDownList OnSelectedIndexChanged

Postby » Fri, 09 Nov 2007 23:08:44 GMT

I have 2 dropdownlists in the Footer of a datagrid:

ddlStartTime and ddlEndTime.  Both contain values like "1:00 AM", "1:15 AM", 
"1:30 AM", etc.

There is also a label named lblTimeDiff.

 I need to dynamically popolate lblTimeDiff.Text (during 
onselectedindexchanged of ddlEndTime) with the difference in minutes between 
ddlStart and ddlEnd in the Footer.  I'm sure javascript will come into play 
here but I have absolutely no idea how to define the eventhandler and 
scripting.  I can do this in tsql using datediff(mi, start_time, end_time), 
just can't seem to dynamically put the return value in the label without a 
postback to the server.  Any ideas?  Thank you very much.



Similar Threads:

1.DataGrid with DropDownLists not responding to OnSelectedIndexChanged

Hello group,

   I have a TemplateColumn containing a DropDownList in my DataGrid. I added
an OnSelectedIndexChanged property in that DropDownList, but I can see in
debug mode that changing the selection will not call my function defined in
OnSelectedIndexChanged (the page reloads, I didn't forget
AutoPostBack=true).
   Is this normal ? Is there a way around it ?

Karine


2.How raise an OnSelectedIndexChanged for an DropDownList in footer of a DataGrid?

Hi!

In a DataGrid I have a 'Add New'-field in the footer. I
want to hide an control (txtNewFe_name) if the value of
cmbNewFe_num is >0. How do I do that? The
OnSelectedIndexChanged does not seem to response to
anything, even though I tryed with just:

Function CheckFe_num()
    Response.Write("Hello World!")
End Function

Best regards / Bengt-Erik

MyPage.aspx
........
........
<FooterTemplate>
    <asp:DropDownList id="cmbNewFe_num" DataSource="<%#
PopulateNewFe_num() %>" DataValueField="Id"
DataTextField="Fe_num" runat="server"
OnSelectedIndexChanged="<%# CheckFe_num() %>"/>
</FooterTemplate>
........
........
........
<FooterTemplate>
    <asp:TextBox id="txtNewFe_name" runat="server"
TextMode="MultiLine" />
</FooterTemplate>
.......
.......

MyPage.aspx.vb
.....
.....
Function CheckFe_num()
    If CType(FindControl("cmbFe_num"),
DropDownList).SelectedItem.Value > 0 Then
        CType(FindControl("txtNewFe_name"), TextBox).Text
= ""
        CType(FindControl("txtNewFe_name"),
TextBox).Visible = False
    Else
        CType(FindControl("txtNewFe_name"),
TextBox).Visible = True
    End If
End Function
......
......


3.How do I raise an OnSelectedIndexChanged for an DropDownList in the footer of a DataGrid?

Hi!

In a DataGrid I have a 'Add New'-field in the footer. I want to hide an
control (txtNewFe_name) if the value of cmbNewFe_num is >0. How do I do
that? The OnSelectedIndexChanged does not seem to response to anything, even
though I tryed with just:

Function CheckFe_num()
    Response.Write("Hello World!")
End Function

Best regards / Bengt-Erik

MyPage.aspx
.......
.......
<FooterTemplate>
    <asp:DropDownList id="cmbNewFe_num" DataSource="<%# PopulateNewFe_num()
%>" DataValueField="Id" DataTextField="Fe_num" runat="server"
OnSelectedIndexChanged="<%# CheckFe_num() %>"/>
</FooterTemplate>
.......
.......
.......
<FooterTemplate>
    <asp:TextBox id="txtNewFe_name" runat="server" TextMode="MultiLine" />
</FooterTemplate>
......
......

MyPage.aspx.vb
....
....
Function CheckFe_num()
    If CType(FindControl("cmbFe_num"), DropDownList).SelectedItem.Value > 0
Then
        CType(FindControl("txtNewFe_name"), TextBox).Text = ""
        CType(FindControl("txtNewFe_name"), TextBox).Visible = False
    Else
        CType(FindControl("txtNewFe_name"), TextBox).Visible = True
    End If
End Function
.....
.....


4.How raise an OnSelectedIndexChanged for an DropDownList in footer of a DataGrid?

Hi!

In a DataGrid I have a 'Add New'-field in the footer. I 
want to hide an control (txtNewFe_name) if the value of 
cmbNewFe_num is >0. How do I do that? The 
OnSelectedIndexChanged does not seem to response to 
anything, even though I tryed with just:

Function CheckFe_num()
    Response.Write("Hello World!")
End Function

Best regards / Bengt-Erik

MyPage.aspx
.......
.......
<FooterTemplate>
    <asp:DropDownList id="cmbNewFe_num" DataSource="<%# 
PopulateNewFe_num() %>" DataValueField="Id" 
DataTextField="Fe_num" runat="server" 
OnSelectedIndexChanged="<%# CheckFe_num() %>"/>
</FooterTemplate>
.......
.......
.......
<FooterTemplate>
    <asp:TextBox id="txtNewFe_name" runat="server" 
TextMode="MultiLine" />
</FooterTemplate>
......
......

MyPage.aspx.vb
....
....
Function CheckFe_num()
    If CType(FindControl("cmbFe_num"), 
DropDownList).SelectedItem.Value > 0 Then
        CType(FindControl("txtNewFe_name"), TextBox).Text 
= ""
        CType(FindControl("txtNewFe_name"), 
TextBox).Visible = False
    Else
        CType(FindControl("txtNewFe_name"), 
TextBox).Visible = True
    End If
End Function
.....
.....

5.Can't databind a dropdownlist in the footer of a datagrid

Hi there, I'm trying to databind a dropdownlist that is in the footer row of a datagrid and I can't get it to work. Here's a chunk of the code:

FP.Intranet.Portal.transloadDB lorries = new FP.Intranet.Portal.transloadDB();
//this next line definitely works as I have used the dsLorries.GetXML to debug and 
//the dataset is definitely populated.
DataSet dsLorries = lorries.GetLorries("BB");
lstLorries.DataSource = dsLorries;
lstLorries.DataTextField = "rl_load_name";
lstLorries.DataBind();

I've put it in the datagrid's itemDatabound event and it just shows up empty.

Please Help!


-- 
Tim McOwan

6. dropdownlist in footer of datagrid

7. Datagrid footer bound dropdownlist

8. Can't add item to dropdownlist in datagrid footer



Return to ASP.NET

 

Who is online

Users browsing this forum: No registered users and 47 guest