issue in gridview[checkbox and images]
' /> '/>
this is my code where i am trying to display checkbox and images my table has columns
itemID Imagespath
1 item1.jpg
2 item2.jpg
3 item3.jpg
4 item4.jpg
but in output it is showing as i want to show only checkbox and image
but开发者_开发百科 now it is showing checkbox along with the [ID i.e 1 ,2,3 etc ] which i should make as [ID as invisiable in design but in code behind i should be able to get the selected value ID]
is there ant way i can remove the gridview border and row border. actually i am trying to amke a checkboxlist alaong with the images, right now even images are not getting displayed
thank you
You can leverage the GridView's DataKeys property for this:
<asp:GridView ID="gvImages" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID">
In your code you can loop through the rows and read the data key for that row and get the checkbox like this:
foreach (GridViewRow gvr in gvImages.Rows)
{
int CustomerID = (int)gvImages.DataKeys[gvr.RowIndex].Value;
CheckBox CheckBox1 = (CheckBox)gvr.FindControl("CheckBox1");
}
Text property of Checkboxes not used for server side value. Checkboxes don't have a value property. They have only Checked property for value.
In your case you should add an hidden field in your row that will hold the value of ID column, and you can get it at server side.
精彩评论