Problem with editable gridview

Posted by MediaMan under ASP.NET on 9/10/2009 | Views : 1415 | Status : [Member] | Replies : 7
Hi guys. I have an editable gridview with one of the columns being a dropdownlist in edit mode. The thing is the datasource of the dropdownlist needs the value(text) of the column next to the one with a dropdownlist. How do I get the value. Please help asp.net beginner .
Please refer to the supporting document.




Responses

Posted by: perfectchourasia-9163 on: 4/3/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/09/editable-gridview.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

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

Posted by: Vuyiswamb on: 9/10/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day MediaMan

This can be accomplished by Template Fields like this

       <asp:TemplateField HeaderText="Parent" SortExpression="Parent">

<ItemTemplate>
<asp:DropDownList ID="drplstparent" runat="server" BackColor="Transparent">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>


Now to bind this , you have to go to the server side, on the rowdatabind event of your grid and bind the grid like this


               if (e.Row.RowType == DataControlRowType.DataRow) //skip header row

{
DropDownList ddl = (DropDownList)e.Row.Cells[2].FindControl("drplstparent");
ddl.DataTextField = "Descr";
ddl.DataValueField = "ID";
ddl.DataBind();
}


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: LucBite on: 9/14/2009 [Member] Starter

Up
0
Down
Hi, Vuyiswa. What do I do if my gridview does not have the databind event.

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

Posted by: Vuyiswamb on: 9/14/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning MediaMan

Right Click on the Gridview and go to properties. A Property dialog box will show. in the Properties , there is a Lightniing like sign , click on it , and scrol , you will see the event.

Thank you for posting at dotnetfdunda

Vuyiswa Maseko



Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: MediaMan on: 9/14/2009 [Member] Starter

Up
0
Down
I have a dropdownlist within my editable gridview.The datasource of the gridview is a datatable method which accepts as a parameter the text of the lable of one of the columns in the gridview.I'm using the code below to try this task but it is not working.

protected void gvServices_DataBinding(object sender, GridViewRowEventArgs e)
{//gvServices is a gridview name
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddl = (DropDownList)e.Row.Cells[3].FindControl("DDLServType");
Label lbl = (Label)e.Row.Cells[2].FindControl("lblServiceName");
string servicename= lbl.Text;
ddl.DataSource = st.getServiceTypes(servicename);
ddl.DataBind();
}
}

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

Posted by: MediaMan on: 9/14/2009 [Member] Starter

Up
0
Down
Please check the attached file to get an understanding of what we are trying to do.Please understand and Help. the due date is around the corner.
 Download source file

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

Posted by: Vuyiswamb on: 9/14/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Hi Gusy,i think we need an Interactive Chat , where i will help you. Please try Skype or Gmail my Username for both is "Vuyiswamb". After i helped you please come back to the forum and Post the asnwer so that it can help others.

Thank you for posting at dotnetFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

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

Login to post response