How to browse a Gridgrouping and to find items ?

Using the templated Datagrid of the .NET toolbar, we can find a component (Label and TextBox for example) with this code : foreach (DataGridItem item in Datagrid1.Items) { Label lbl = (Label) item.FindControl("labelName"); TextBox box = (TextBox) item.FindControl("textboxName"); ...... } Using a templated GridGroupingControl how can we browse it and find items (like Label or TextBox). Thank''s

4 Replies

AD Administrator Syncfusion Team February 22, 2006 11:50 PM UTC

Hi Claudio, You can use the GridGroupingControl1.FormEditCell.FindControl method. Take a look at GridGroupingControl1_BarButtonItemClicked() event in the Editing\FormEditMode sample (FormEditModeDemo.aspx.cs). Here is a snippet of code used for a TextBox control: TextBox tb = this.GridGroupingControl1.FormEditCell.FindControl("CustomerIDTB") as TextBox; Regards Arun


CL Claudio February 23, 2006 02:24 PM UTC

Thank you but how can I programmatically go to a ''Record'' (without have to click on it) in my GridGroupingControl. I''d like to know also how to create a Template column in a GridGroupingControl (for example a template column using a Label and a TextBox controls) and databind data with a column from a dataset. After that I will write in my Page_Load() definition : GridGroupingControl1.DataSource = dataset1; GridGroupingControl1.DataBind(); To resume I''d like to have in one column of my GridGroupingControl a Label and a TextBox databinded with the same column from a dataset, so in my Label and TextBox I will have the same information. This is not working : - in my aspx file <%#GetUserId(Container)%> <%#GetUserId(Container)%> - in my aspx.cs file protected string GetUserId(GridCell container) { string TEST; Record rowRecord=container.Row.Record; TEST = rowRecord.GetValue("user_id").ToString(); return TEST; } I get this two errors : "Object reference not set to an instance of an object." Line 45: TEST = rowRecord.GetValue("user_id").ToString(); ''TextBox'' cannot have children of type ''DataBoundLiteralControl''. Line 30: >Hi Claudio, > >You can use the GridGroupingControl1.FormEditCell.FindControl method. Take a look at GridGroupingControl1_BarButtonItemClicked() event in the Editing\FormEditMode sample (FormEditModeDemo.aspx.cs). Here is a snippet of code used for a TextBox control: > >TextBox tb = this.GridGroupingControl1.FormEditCell.FindControl("CustomerIDTB") as TextBox; > >Regards >Arun >


CL Claudio February 23, 2006 02:28 PM UTC

In my aspx file : < ItemTemplate > < asp:Label id="Label1" runat="server" > < % # GetUserId(Container) % > < / asp:Label > < asp:TextBox id="TextBox2" runat="server" > < % #GetUserId(Container) % > < / asp:TextBox > < / ItemTemplate > >Thank you but how can I programmatically go to a ''Record'' (without have to click on it) in my GridGroupingControl. >I''d like to know also how to create a Template column in a GridGroupingControl (for example a template column using a Label and a TextBox controls) and databind data with a column from a dataset. After that I will write in my Page_Load() definition : > >GridGroupingControl1.DataSource = dataset1; >GridGroupingControl1.DataBind(); > >To resume I''d like to have in one column of my GridGroupingControl a Label and a TextBox databinded with the same column from a dataset, so in my Label and TextBox I will have the same information. > >This is not working : > > - in my aspx file > > > > > <%#GetUserId(Container)%> > > > <%#GetUserId(Container)%> > > > > > - in my aspx.cs file > >protected string GetUserId(GridCell container) >{ > string TEST; > Record rowRecord=container.Row.Record; > TEST = rowRecord.GetValue("user_id").ToString(); > return TEST; >} > >I get this two errors : > >"Object reference not set to an instance of an object." >Line 45: TEST = rowRecord.GetValue("user_id").ToString(); > >''TextBox'' cannot have children of type ''DataBoundLiteralControl''. >Line 30: > >>Hi Claudio, >> >>You can use the GridGroupingControl1.FormEditCell.FindControl method. Take a look at GridGroupingControl1_BarButtonItemClicked() event in the Editing\FormEditMode sample (FormEditModeDemo.aspx.cs). Here is a snippet of code used for a TextBox control: >> >>TextBox tb = this.GridGroupingControl1.FormEditCell.FindControl("CustomerIDTB") as TextBox; >> >>Regards >>Arun >>


CL Claudio February 23, 2006 03:41 PM UTC

Actually it is working now ! So you can forget my last messages. But I still have problems. Can I programmatically go to a specific row (without have to click on it) in my GridGroupingControl ? because I just want to find my control in a specific row. Now I know i must use the FindControl method. This is my aspx file code for my Template column in the attached file. >In my aspx file : > >< ItemTemplate > > < asp:Label id="Label1" runat="server" > > < % # GetUserId(Container) % > > < / asp:Label > > < asp:TextBox id="TextBox2" runat="server" > > < % #GetUserId(Container) % > > < / asp:TextBox > >< / ItemTemplate > > >>Thank you but how can I programmatically go to a ''Record'' (without have to click on it) in my GridGroupingControl. >>I''d like to know also how to create a Template column in a GridGroupingControl (for example a template column using a Label and a TextBox controls) and databind data with a column from a dataset. After that I will write in my Page_Load() definition : >> >>GridGroupingControl1.DataSource = dataset1; >>GridGroupingControl1.DataBind(); >> >>To resume I''d like to have in one column of my GridGroupingControl a Label and a TextBox databinded with the same column from a dataset, so in my Label and TextBox I will have the same information. >> >>This is not working : >> >> - in my aspx file >> >> >> >> >> <%#GetUserId(Container)%> >> >> >> <%#GetUserId(Container)%> >> >> >> >> >> - in my aspx.cs file >> >>protected string GetUserId(GridCell container) >>{ >> string TEST; >> Record rowRecord=container.Row.Record; >> TEST = rowRecord.GetValue("user_id").ToString(); >> return TEST; >>} >> >>I get this two errors : >> >>"Object reference not set to an instance of an object." >>Line 45: TEST = rowRecord.GetValue("user_id").ToString(); >> >>''TextBox'' cannot have children of type ''DataBoundLiteralControl''. >>Line 30: >> >>>Hi Claudio, >>> >>>You can use the GridGroupingControl1.FormEditCell.FindControl method. Take a look at GridGroupingControl1_BarButtonItemClicked() event in the Editing\FormEditMode sample (FormEditModeDemo.aspx.cs). Here is a snippet of code used for a TextBox control: >>> >>>TextBox tb = this.GridGroupingControl1.FormEditCell.FindControl("CustomerIDTB") as TextBox; >>> >>>Regards >>>Arun >>>

aspx.zip

Loader.
Up arrow icon