1: <asp:DataList ID="newsgallerylist" runat="server" RepeatDirection="Horizontal" RepeatColumns="6" DataKeyField="PhotoID">
2: <ItemTemplate>
3: <table>
4: <tr>
5: <td>
6: <asp:CheckBox ID="Imagecheck" runat="server" AutoPostBack="true" Checked='<%#Eval("ActiveGallery") %>'/>
7: td>
8: <td >
9: <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("PhotoLink") %>'/>
10: td>
11: tr>
12: table>
13:
14: ItemTemplate>
15:
16: asp:DataList>
C# code to get datakey from datalist at runtime
1: public void getdatakey()
2: {
3: ArrayList photoid = new ArrayList();
4: ArrayList UpdatePhoto = new ArrayList();
5: CheckBox ch1;
6: Int32 mem_id = 0;
7: for (int j = 0; j < newsgallerylist.Items.Count; j++)
8: {
9: ch1 = (CheckBox)(newsgallerylist.Items[j].FindControl("Imagecheck"));
10: if (ch1.Checked == true)
11: {
12: mem_id = Convert.ToInt32(newsgallerylist.DataKeys[j]);
13: photoid.Add(mem_id);
14: }
15: else
16: {
17: mem_id = Convert.ToInt32(newsgallerylist.DataKeys[j]);
18: UpdatePhoto.Add(mem_id);
19:
20: }
21: }
22: foreach (int id in photoid)
23: {
24: BusinessObjects.clsHomePhotoGallery objphotoid = new BusinessObjects.clsHomePhotoGallery();
25: objphotoid.updateAdminphotos(id);
26: }
27: foreach (int id in UpdatePhoto)
28: {
29: BusinessObjects.clsHomePhotoGallery objphotoid1 = new BusinessObjects.clsHomePhotoGallery();
30: objphotoid1.updateAdminphotos1(id);
31:
32: }
33: }
hello pulkit u solved my prob
ReplyDelete