hii..
to display the data you have selected in checkbox can be populate it in checkbox changed event as follows
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
//TextBox tb = ((Control)sender).NamingContainer.FindControl("TextBox2") as TextBox;
CheckBox chk = ((Control)sender).NamingContainer.FindControl("CheckBox1") as CheckBox;
string requiredtext = chk.Text;
Response.Write(requiredtext);
}
kamilacbe
Junior Poster in Training
77 posts since Jun 2010
Reputation Points: 10
Solved Threads: 10
hi..
yup it is ..as you have done in your sample inside your item template tag..then pass the column which has to be populated as the text for that checkbox...then in your change event go for this c# part .
Do u want the snippet for design too
kamilacbe
Junior Poster in Training
77 posts since Jun 2010
Reputation Points: 10
Solved Threads: 10
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4"
onrowdatabound="GridView1_RowDataBound"
onselectedindexchanged="GridView1_SelectedIndexChanged"
onrowupdating="GridView1_RowUpdating"
onrowediting="GridView1_RowEditing">
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:TemplateField>
<ItemTemplate >
<asp:CheckBox ID="CheckBox1" runat="server" Font-Italic="True" Text ='<%#Eval("name")%>'
oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="True" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:GridView>
In the c# code uncomment the textbox and pass the value to textobject you can find the output in gridview textbox. or go for response .write...
kamilacbe
Junior Poster in Training
77 posts since Jun 2010
Reputation Points: 10
Solved Threads: 10
hii..
I use datasource to populate the gridview...can you be precise if u dont mind...
this is how i bounded the data...guess you would know this
if (!IsPostBack)
{
con.ConnectionString = constr;
con.Open();
SqlDataAdapter ada = new SqlDataAdapter("select * from Table3", con);
ada.Fill(ds, "Table3");
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
GridView1.DataSource = ds;
GridView1.DataBind();
}
kamilacbe
Junior Poster in Training
77 posts since Jun 2010
Reputation Points: 10
Solved Threads: 10