I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid> 11 1886
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
"Manish Bafna" wrote:
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
"Manish Bafna" wrote:
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
>
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
>
-----------------------DataGrid-------------------------------------------
>
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
>
>
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
"Manish Bafna" wrote:
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
"Manish Bafna" wrote:
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
>
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
"Mike Collins" wrote:
>
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Hi,
Try this one:
this.dgMenus.Ed itItemIndex = e.Item.ItemInde x;
dgMenus.Items[this.DataGrid1. EditItemIndex].FindControl("t xtName") as TextBox
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
"Manish Bafna" wrote:
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
>
"Manish Bafna" wrote:
>
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
>
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
>
-----------------------DataGrid-------------------------------------------
>
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
>
>
I had to change your code where you had the "as TextBox" because it caused an
error to the following:
this.dgDropDown Menus.EditItemI ndex = e.Item.ItemInde x;
TextBox option =
(TextBox)dgDrop DownMenus.Items[this.dgDropDown Menus.EditItemI ndex].FindControl("t xtName");
Then I got the following error: error: identifier 'option' out of scope,
when I checked the object "option" after running the code. It was not a run
time error, I did a quick watch.
I appreciate your patience and help in trying to help me figure this out.
"Manish Bafna" wrote:
Hi,
Try this one:
this.dgMenus.Ed itItemIndex = e.Item.ItemInde x;
dgMenus.Items[this.DataGrid1. EditItemIndex].FindControl("t xtName") as TextBox
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
"Manish Bafna" wrote:
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
>
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
"Mike Collins" wrote:
>
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
"Manish Bafna" wrote:
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
>
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
"Mike Collins" wrote:
>
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Hi,
so finally it was solved or you r still getting some errors?
"Mike Collins" wrote:
I had to change your code where you had the "as TextBox" because it caused an
error to the following:
this.dgDropDown Menus.EditItemI ndex = e.Item.ItemInde x;
TextBox option =
(TextBox)dgDrop DownMenus.Items[this.dgDropDown Menus.EditItemI ndex].FindControl("t xtName");
Then I got the following error: error: identifier 'option' out of scope,
when I checked the object "option" after running the code. It was not a run
time error, I did a quick watch.
I appreciate your patience and help in trying to help me figure this out.
"Manish Bafna" wrote:
Hi,
Try this one:
this.dgMenus.Ed itItemIndex = e.Item.ItemInde x;
dgMenus.Items[this.DataGrid1. EditItemIndex].FindControl("t xtName") as TextBox
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
>
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
>
>
"Manish Bafna" wrote:
>
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
>
"Manish Bafna" wrote:
>
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
>
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
>
-----------------------DataGrid-------------------------------------------
>
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
>
>
Still an error.
error: identifier 'option' out of scope, when I checked the object "option"
after running the code. It was not a run time error, I did a quick watch and
saw it.
"Manish Bafna" wrote:
Hi,
so finally it was solved or you r still getting some errors?
"Mike Collins" wrote:
I had to change your code where you had the "as TextBox" because it caused an
error to the following:
this.dgDropDown Menus.EditItemI ndex = e.Item.ItemInde x;
TextBox option =
(TextBox)dgDrop DownMenus.Items[this.dgDropDown Menus.EditItemI ndex].FindControl("t xtName");
Then I got the following error: error: identifier 'option' out of scope,
when I checked the object "option" after running the code. It was not a run
time error, I did a quick watch.
I appreciate your patience and help in trying to help me figure this out.
"Manish Bafna" wrote:
Hi,
Try this one:
this.dgMenus.Ed itItemIndex = e.Item.ItemInde x;
dgMenus.Items[this.DataGrid1. EditItemIndex].FindControl("t xtName") as TextBox
>
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
>
"Mike Collins" wrote:
>
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
"Manish Bafna" wrote:
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
>
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
"Mike Collins" wrote:
>
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
"Manish Bafna" wrote:
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
>
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
>
"Mike Collins" wrote:
>
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
-----------------------DataGrid-------------------------------------------
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
Hi,
I think the error u r getting in quick watch is the bug in the microsoft
product.See below link: http://www.kbalertz.com/Feedback_814828.aspx
I think you r now able to get text of textbox in datagrid.
"Mike Collins" wrote:
Still an error.
error: identifier 'option' out of scope, when I checked the object "option"
after running the code. It was not a run time error, I did a quick watch and
saw it.
"Manish Bafna" wrote:
Hi,
so finally it was solved or you r still getting some errors?
"Mike Collins" wrote:
I had to change your code where you had the "as TextBox" because it caused an
error to the following:
>
this.dgDropDown Menus.EditItemI ndex = e.Item.ItemInde x;
TextBox option =
(TextBox)dgDrop DownMenus.Items[this.dgDropDown Menus.EditItemI ndex].FindControl("t xtName");
>
Then I got the following error: error: identifier 'option' out of scope,
when I checked the object "option" after running the code. It was not a run
time error, I did a quick watch.
>
I appreciate your patience and help in trying to help me figure this out.
>
"Manish Bafna" wrote:
>
Hi,
Try this one:
this.dgMenus.Ed itItemIndex = e.Item.ItemInde x;
dgMenus.Items[this.DataGrid1. EditItemIndex].FindControl("t xtName") as TextBox
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Sorry for the incomplete response. Below is the event that is running, and I
am getting an error on the first line of the method "string option..."
>
private void dgDropDownMenus _EditCommand(ob ject source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
string option = ((TextBox)e.Ite m.FindControl(" txtName")).Text ;
Server.Transfer ("../surveys/manageansweropt ions.aspx?Answe rGroupID=" +
dgDropDownMenus .DataKeys[e.Item.ItemInde x].ToString() + "&CallingPage=M anage
Dropdowns Page&ReturnURL= ManageDropDowns .aspx&option=" +
rblOption.Selec tedItem.Value + "&GroupName =" +
dgDropDownMenus .Items[e.Item.ItemInde x].Cells[2].Text);
}
>
>
"Manish Bafna" wrote:
>
Hi,
can you please tell at which line you are getting this error?Most probably
you would be using this line of findcontrol in update event of DataGrid.If
you give details as to where r using this code of findcontrol or in which
event u r using then only i would be able to help you out.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
Thanks, but I get an error: Object reference not set to an instance of an
object. Any idea on why that is happening?
>
"Manish Bafna" wrote:
>
Hi,
It should be:
DataGrid dgDropDownMenus = (DataGrid)sende r;
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() !=
"Footer")
{
string option = ((TextBox )e.Item.FindCon trol("txtName") ).Text;
}
Although i have written this code for Datagrid, you can use same for
gridview with little or no modification.
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"Mike Collins" wrote:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control. Thank you.
>
string option =
((TextBox)dgDro pDownMenus.Item s[e.Item.ItemInde x].FindControl("t xtName")).Text;
>
-----------------------DataGrid-------------------------------------------
>
<asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
absolute; TOP: 0px"
runat="server" DataKeyField="D ropDownMenuID" CellPadding="0"
BackColor="Whit e" BorderStyle="No ne" Font-Bold="True" BorderWidth="1p x"
BorderColor="#9 99999" GridLines="Vert ical" HorizontalAlign ="Center"
AutoGenerateCol umns="False" Width="100%">
<FooterStyle ForeColor="Blac k" BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" HorizontalAlign ="Center"
Height="10px" ForeColor="Whit e" VerticalAlign=" Middle"
BackColor="#008 A8C"></SelectedItemSty le>
<EditItemStyl e HorizontalAlign ="Center" Height="10px" Width="50px"
VerticalAlign=" Middle"></EditItemStyle>
<AlternatingIte mStyle HorizontalAlign ="Center" Height="10px"
VerticalAlign=" Middle" BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle HorizontalAlign ="Center" Height="10px" ForeColor="Blac k"
VerticalAlign=" Middle"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Wrap="False" CssClass="datag ridheader"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="<img border="0" src="../images/edit_icon.gif"> "
HeaderText="Edi t" CommandName="Ed it">
<HeaderStyle HorizontalAlign ="Center" Width="5%"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Nam e">
<HeaderStyle Width="25px"></HeaderStyle>
<ItemTemplate >
<asp:Label id="lblName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="txtName" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Displ ayName") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Des cription">
<HeaderStyle Width="70%"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.Descr iption") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox id="Textbox1" runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.Descr iption") %>'>
</asp:TextBox>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>
<PagerStyle VerticalAlign=" Middle" NextPageText="N ext -->"
PrevPageText="<-- Previous"
HorizontalAlign ="Center" ForeColor="Blac k" BackColor="#999 999"
Wrap="False" Mode="NumericPa ges"></PagerStyle>
</asp:datagrid>
>
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James G. Beldock |
last post by:
I have seen the following behavior: when issuing a Page.FindControl() for a
control which exists in an item template (from within an ItemDataBound()
event, for example), I get nulls back regularly. Has anyone seen this
before? It's pretty aggravating to have to iterate through the controls in
each grid cell to find the ones I need, especially since finding those cells
is not always easy. Here's my ItemDataBound() handler:
private void...
|
by: Neo Geshel |
last post by:
This works:
<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>
But this DOES NOT work:
<form>
|
by: Neo Geshel |
last post by:
After pouring over about a dozen sites that clearly dealt with ClientID
all by itself, I came to the realization that about 2/3+ of them were
doing it wrong. It is indeed impossible to grab the Client ID of a form
field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At
least, not without extra work.
How did I do this? I created a new DataGrid from scratch, with a form
above it and a form inside of it. This was a page...
|
by: christof |
last post by:
How to do it:
My page:
<asp:DataList ID="dataListRoleMembers" ...>
....
<FooterTemplate>
<asp:LinkButton ID="btnAddMember" runat="server"
OnClick="btnAddMember_Click">Add...</asp:LinkButton>
<asp:TextBox ID="txtAddMember" runat="server"></asp:TextBox>
|
by: encoad |
last post by:
Hi everyone,
I'm slowly going mad with Masterpages and the FindControl. After a
couple days of figuring out how to use the FindControl command from
within a Masterpage, I still can't explain why this code does not
function. As you can see if you compile it with 2005, clicking
"Button" will achieve the desired result of displaying the contents of
the textbox, however the test(); function called from Page_Load does
not do anything. ...
| |
by: Henry Stock |
last post by:
I don't seem to understand how to use the value:
Request.ServerVariables("remote_addr")
I am trying to pass the ip address of a sending web client in the body of an
email message.
When I compile the following code I get the this error message:
Error 1 'System.Web.HttpRequest.ServerVariables' is a 'property' but is used
like a 'method' D:\Projects\sample\comments.aspx.cs 38 78
|
by: AAaron123 |
last post by:
Me.FindControl("MissionScheduleID"), below returns null.
Do you know what I'm doing wrong?
Thanks
***In my .aspx file I have:
asp:Content ID="Content3" contentplaceholderid="MainMasterLeftDataID"
runat="server">
|
by: Hillbilly |
last post by:
Maybe this is or isn't some kind of bug but it sure is goofy and remains a
mystery that really has me puzzled for two reasons...
// goofy syntax functions as expected...
Panel finalStepButton =
Page.Master.FindControl("CenterPanelContent
$ItemBuilderWizard
$StepNavigationTemplateContainerID
$StepNavFinalStepButton") as Panel;
|
by: AAaron123 |
last post by:
I'm this far in determining the correct code to find a textbox I need to
set.
Me.Master.FindControl("Body1").FindControl("Form2").FindControl("Table2").FindControl("TableRow7").FindControl("TableCellR7C2S2").FindControl("RightCPH").FindControl("div1").FindControl("div2").FindControl("LoginView1")
Took me longer than I want to say to produce the above and I'm not there
yet.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |