IT Community - Software Programming, Web Development and Technical Support

DropdownList in Editable Datagrid

This is a discussion on DropdownList in Editable Datagrid within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, I m using the editable Datagrid . In the edit mode i have dropdown list . when i click the edit ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-26-2007, 05:11 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default DropdownList in Editable Datagrid

Hi,
I m using the editable Datagrid . In the edit mode i have dropdown list . when i click the edit function my dropdown should focus to the selected value. when i click the edit function my dropdown get focus in to first value .







shaalini.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-26-2007, 05:18 AM
satheesh satheesh is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 95
satheesh is on a distinguished road
Default Re: DropdownList in Editable Datagrid

Hi shaalini,

U can use the function of on prerender in dropdownlist to focus the selected value
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-26-2007, 06:05 AM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: DropdownList in Editable Datagrid

hi ,
Try this
<aspataGrid id="DataGrid1" AutoGenerateColumns="False" ItemStyle-CssClass="cdb-AltRow"
AlternatingItemStyle-CssClass="cdb-AltRow2"
DataKeyField="ProductID" OnUpdateCommand="DataGrid1_Update" OnEditCommand="DataGrid1_Edit"
OnCancelCommand="DataGrid1_Cancel" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Discontinued">
<ItemTemplate>
<asp:Label ID="lblDiscontinued"
Text='<%#ShowVal(Convert.ToBoolean(
DataBinder.Eval(Container.DataItem, "Discontinued").ToString()) )%>'
Runat="server" />
</ItemTemplate>

<EditItemTemplate>
<asp:Label runat="server" id="lblProductID" Visible="False"
Text='<%#
DataBinder.Eval(Container.DataItem, "ProductId") %>'/>
<asp:Label ID="lblEditDiscontinued"
Text='<%#ShowVal(Convert.ToBoolean(
DataBinder.Eval(Container.DataItem, "Discontinued").ToString() ))%>'
Runat="server" />
<aspropDownList id="ddlDiscontinued"
DataSource="<%# BindTheDiscontinued() %>"
OnPreRender="SetDropDownIndex"
DataTextField="Discontinued"
DataValueField="Discontinued"
runat="server" />
</EditItemTemplate>

</asp:TemplateColumn>

<asp:EditCommandColumn
EditText="Edit" CancelText="Cancel" UpdateText="Update"
ItemStyle-Width="100px"
HeaderText="Commands" />
</Columns>
</aspataGrid>

Code Behind

string strDiscontinued;

public void DataGrid1_Edit(Object sender, DataGridCommandEventArgs e)
{
strDiscontinued = ((Label )e.Item.FindControl("lblDiscontinued")).Text;
DataGrid1.EditItemIndex = (int)e.Item.ItemIndex;
BindGrid();
}

protected void SetDropDownIndex(Object sender ,System.EventArgs e )
{
DropDownList ed ;
ed = (DropDownList) sender;
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strDiscontinu ed));
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-26-2007, 06:07 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: DropdownList in Editable Datagrid

hi blue sky,
Thanks , it works fine
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create dropdownlist at runtime shaalini ASP and ASP.NET Programming 1 02-14-2008 08:16 PM
how to bind values of onedropdownlist to another dropdownlist in another page? poornima ASP and ASP.NET Programming 0 02-03-2008 09:07 PM
create Editable label without postback shaalini ASP and ASP.NET Programming 4 10-18-2007 02:18 AM
Problem in my DropDownList SelectedIndexChanged. S.Vinothkumar ASP and ASP.NET Programming 2 10-11-2007 11:47 PM
How to get the index value of the dropdown from the dropdownlist item Sathish Kumar C# Programming 0 03-12-2007 12:14 PM


All times are GMT -7. The time now is 07:18 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0