Click here to Skip to main content
16,010,918 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDataset Pin
berba4-Mar-13 1:00
berba4-Mar-13 1:00 
AnswerRe: Dataset Pin
Blikkies4-Mar-13 3:05
professionalBlikkies4-Mar-13 3:05 
Questiondropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 20:30
demoninside93-Mar-13 20:30 
AnswerRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 21:44
professionalKarthik Harve3-Mar-13 21:44 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 21:56
demoninside93-Mar-13 21:56 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 22:00
professionalKarthik Harve3-Mar-13 22:00 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 22:13
demoninside93-Mar-13 22:13 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 22:23
professionalKarthik Harve3-Mar-13 22:23 
update the edit template as below.

ASP.NET
<asp:TemplateField HeaderText="Cost Code">
    <EditItemTemplate>
        <asp:DropDownList ID="ddlCost_Code" runat="server"   AutoPostBack="true"        
        onselectedindexchanged="ddlCost_Code_SelectedIndexChanged"
        AppendDataBoundItems="True">        
        <asp:ListItem Value="0">-Select-</asp:ListItem>        
        </asp:DropDownList>
        
        <asp:Label ID="lblCostCode_Hd" visible="false" runat="server" Text='<%# Bind("Cost_Code") %>'></asp:Label>
    
    </EditItemTemplate>
    <ItemTemplate>
        <asp:Label ID="Label6" runat="server" Text='<%# Bind("Cost_Code") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>


take one hidden label "lblCostCode_Hd" which hold the selected Cost Code. and in row databound add below code.

C#
ddlCost_Code.DataSource = dt_for_CostCode;
ddlCost_Code.DataTextField = "Cost_Code";
ddlCost_Code.DataValueField = "Proposalno";
ddlCost_Code.DataBind();

Label lbl = (Label)e.Row.FindControl("lblCostCode_Hd");
if(lbl != null)
{
    ddlCost_Code.Items.FindByText(lbl.Text).Selected = true;
}


so, this will select the particular code which you have selected.

hope it works.
Vande Matharam - Jai Hind

GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 22:27
demoninside93-Mar-13 22:27 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 23:23
professionalKarthik Harve3-Mar-13 23:23 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 23:35
demoninside93-Mar-13 23:35 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 23:38
professionalKarthik Harve3-Mar-13 23:38 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 23:53
demoninside93-Mar-13 23:53 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve3-Mar-13 23:59
professionalKarthik Harve3-Mar-13 23:59 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
demoninside93-Mar-13 23:57
demoninside93-Mar-13 23:57 
GeneralRe: dropdownlist auto select first value in gridview with edit mode Pin
Karthik Harve4-Mar-13 0:04
professionalKarthik Harve4-Mar-13 0:04 
Questionhow to make multiple entries for a book in database for multiple copies of the same book in a library? Pin
Madhubala Ganesan2-Mar-13 6:33
Madhubala Ganesan2-Mar-13 6:33 
AnswerRe: how to make multiple entries for a book in database for multiple copies of the same book in a library? Pin
Bernhard Hiller3-Mar-13 20:35
Bernhard Hiller3-Mar-13 20:35 
QuestionJson + asp.net Pin
jojoba20112-Mar-13 4:45
jojoba20112-Mar-13 4:45 
AnswerRe: Json + asp.net Pin
jkirkerx4-Mar-13 10:36
professionaljkirkerx4-Mar-13 10:36 
QuestionRe: Json + asp.net Pin
jojoba20119-Mar-13 17:58
jojoba20119-Mar-13 17:58 
AnswerRe: Json + asp.net Pin
jkirkerx9-Mar-13 18:19
professionaljkirkerx9-Mar-13 18:19 
Questionerror '80004003', Object reference not set to an instance of an object. Pin
notahack2-Mar-13 4:37
notahack2-Mar-13 4:37 
AnswerRe: error '80004003', Object reference not set to an instance of an object. Pin
Richard MacCutchan2-Mar-13 5:42
mveRichard MacCutchan2-Mar-13 5:42 
Questionplugging in twitter and facebook into the web application Pin
Member 87018131-Mar-13 3:04
Member 87018131-Mar-13 3:04 

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.