Access List Box in template field of Grid in its own List Box Selected Index Changed Event.

Posted by Chaitanyat21 under Regular Expressions on 12/20/2010 | Points: 10 | Views : 2034 | Status : [Member] | Replies : 3
Hi All,

I am trying to access the multiple items selected in the List Box (lblgrideditcountry) which is in template field of Grid view. The list box will be available only in editing event as its placed as edit template in grid view, but I am not successful in doing so.

</asp:TemplateField>
<asp:TemplateField HeaderText=" Country">
<EditItemTemplate>
<asp:Label ID="lblgrideditcountry" runat="server" CssClass="clslabel"
Text='<%# Bind("AM_AuditCountry") %>'></asp:Label>
<br />
<asp:ListBox ID="lstgridcountry" runat="server" AutoPostBack="True"
DataSourceID="dsCountryName" DataTextField="CountryName"
DataValueField="CountryName" Height="65px"
onselectedindexchanged="lstgridcountry_SelectedIndexChanged"
SelectionMode="Multiple" Width="180px"></asp:ListBox>
<br />



I have tried using the following the code

{
gridamIU.EditIndex = e.NewEditIndex;

gridfill(gridamIU);
SeltlstCountry=(ListBox)( gridamIU.Rows[gridamIU.EditIndex].FindControl("lstgridcountry"));
SeltlstLocation = (ListBox)gridamIU.Rows[gridamIU.EditIndex].FindControl("lstgridlocation");
}

protected void lstgridcountry_SelectedIndexChanged(object sender, EventArgs e)
{

string strSelectedItems = "";
strSelectedItems= ReadSelectedListItems(SeltlstCountry);
objDataBoundBL.ListBoxValueTextWithParameter_AR("SPR_Eaudit_AM_AuditItem", SeltlstLocation, "Audit Facility", strSelectedItems, ConfigurationManager.AppSettings["ConEaudit"].ToString());


//foreach (System.Web.UI.WebControls.GridViewRow dg in gridamIU.Rows)
//{

// strSelectedItems = ReadSelectedListItems(((ListBox)dg.Cells[3].FindControl("lstgridcountry")));

//}


}



Please help me...

T.Chaitanya kumar


Responses

Posted by: Chaitanyat21 on: 12/20/2010 [Member] Starter | Points: 25

Up
0
Down
Hi All,
Good Day

My issue got resolved. No need to spend time on this.


Thanx

T.Chaitanya kumar

Chaitanyat21, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chvrsri on: 12/20/2010 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
Hi Chaitanya,

Please share what mistake you did and also share how did you resolved the issue. So that it might help some one to not to make the same mistake.

Please also do mark the question as resolved.....

Thanks,
Radha Srikanth

Chaitanyat21, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chaitanyat21 on: 12/20/2010 [Member] Starter | Points: 25

Up
0
Down
Hi All,

I used foreach loop in the listbox selected index changed event to get the listbox which is populated or avialbale when row editing event is fired. the code as follows:

foreach (System.Web.UI.WebControls.GridViewRow dg in gridamIU.Rows)
{

strSelectedItems = ReadSelectedListItems(((ListBox)dg.Cells[4].FindControl("lstgridcountry")));

}


thanx...


T.Chaitanya kumar

Chaitanyat21, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response