Click here to Skip to main content
16,004,854 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to get data from Database? Pin
_AK_3-Jan-07 23:32
_AK_3-Jan-07 23:32 
QuestionHttpWebRequest and HttpWebResponse with .aspx files Pin
Kanjinghat3-Jan-07 19:01
Kanjinghat3-Jan-07 19:01 
AnswerRe: HttpWebRequest and HttpWebResponse with .aspx files Pin
Mark J. Miller4-Jan-07 3:26
Mark J. Miller4-Jan-07 3:26 
GeneralRe: HttpWebRequest and HttpWebResponse with .aspx files Pin
Kanjinghat4-Jan-07 17:42
Kanjinghat4-Jan-07 17:42 
GeneralRe: HttpWebRequest and HttpWebResponse with .aspx files Pin
Mark J. Miller5-Jan-07 3:06
Mark J. Miller5-Jan-07 3:06 
QuestionRegular Expression Pin
Member 36789843-Jan-07 18:51
Member 36789843-Jan-07 18:51 
AnswerRe: Regular Expression Pin
_AK_3-Jan-07 20:26
_AK_3-Jan-07 20:26 
QuestionUpdate or Insert into DB Pin
varshavmane3-Jan-07 18:43
varshavmane3-Jan-07 18:43 
Hi all,

I have GridView which contains few columns of checkbox.My problem is how do I insert or Update Database on save button click(this button is outside the GridView).Following is the code what I have use but not getting where do U update DB:


<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" Width="100%" CellPadding="4"
ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="FormID" HeaderText="FormID"
InsertVisible="False" ReadOnly="True" SortExpression="FormID">
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="FormName" HeaderText="Form Name"
SortExpression="Name" >
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Add" SortExpression="Add">
<ItemTemplate>
<center>
<asp:CheckBox ID="chkAdd" runat="server" Checked='<%# IsActive(Eval("Add")) %>' />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Modify" SortExpression="Modify">
<ItemTemplate>
<center>
<asp:CheckBox ID="chkModify" runat="server" Checked='<%# IsActive(Eval("Modify")) %>' />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete" SortExpression="Delete">
<ItemTemplate>
<center>
<asp:CheckBox ID="chkDelete" runat="server" Checked='<%# IsActive(Eval("Delete")) %>' />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View" SortExpression="View">
<ItemTemplate>
<center>
<asp:CheckBox ID="chkView" runat="server" Checked='<%# IsActive(Eval("View")) %>' />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Print" SortExpression="Print">
<ItemTemplate>
<center>
<asp:CheckBox ID="chkPrint" runat="server" Checked='<%# IsActive(Eval("Print")) %>' />
</center>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>



Public Shared Function IsActive(ByVal sValue As String) As Boolean
If sValue = "True" Then
Return True
Else
Return False
End If
End Function



Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim index As Integer
Dim sCB1Add As String = String.Empty
Dim sCB2Modify As String = String.Empty
Dim sCB3Delete As String = String.Empty
Dim sCB4View As String = String.Empty
Dim sCB5Print As String = String.Empty

For index = 0 To GridView1.Rows.Count - 1
Dim gvRow As GridViewRow = GridView1.Rows(index)
If CType(gvRow.FindControl("chkAdd"), CheckBox).Checked Then
sCB1Add = "1"
Else
sCB1Add = "0"
End If
If CType(gvRow.FindControl("chkModify"), CheckBox).Checked Then
sCB2Modify = "1"
Else
sCB2Modify = "0"
End If
If CType(gvRow.FindControl("chkDelete"), CheckBox).Checked Then
sCB3Delete = "1"
Else
sCB3Delete = "0"
End If
If CType(gvRow.FindControl("chkView"), CheckBox).Checked Then
sCB4View = "1"
Else
sCB4View = "0"
End If
If CType(gvRow.FindControl("chkPrint"), CheckBox).Checked Then
sCB5Print = "1"
Else
sCB5Print = "0"
End If
Next

End Sub

Please help me as I am new for 2005 Version.

Thanks....
AnswerRe: Update or Insert into DB Pin
Mark J. Miller4-Jan-07 3:09
Mark J. Miller4-Jan-07 3:09 
Questioncoding for crystal reports in ASP.NET Pin
chathu03j3-Jan-07 18:38
chathu03j3-Jan-07 18:38 
Questionpop up box on selected index change in combobox Pin
Jack Dorsen3-Jan-07 17:49
Jack Dorsen3-Jan-07 17:49 
AnswerRe: pop up box on selected index change in combobox Pin
Not Active3-Jan-07 17:55
mentorNot Active3-Jan-07 17:55 
AnswerRe: pop up box on selected index change in combobox Pin
MayurPanchal3-Jan-07 19:33
MayurPanchal3-Jan-07 19:33 
QuestionEmails Problem!!! Pin
ADY0073-Jan-07 12:38
ADY0073-Jan-07 12:38 
AnswerRe: Emails Problem!!! Pin
Venkatesh Mookkan3-Jan-07 16:01
Venkatesh Mookkan3-Jan-07 16:01 
GeneralRe: Emails Problem!!! Pin
ADY0074-Jan-07 9:43
ADY0074-Jan-07 9:43 
GeneralRe: Emails Problem!!! Pin
Venkatesh Mookkan4-Jan-07 15:27
Venkatesh Mookkan4-Jan-07 15:27 
QuestionEmbedded Resources for Localization .NET 1.1 Pin
dioey3-Jan-07 8:59
dioey3-Jan-07 8:59 
AnswerRe: Embedded Resources for Localization .NET 1.1 Pin
minhpc_bk3-Jan-07 15:35
minhpc_bk3-Jan-07 15:35 
QuestionServer side not firing Pin
DanB19833-Jan-07 8:33
DanB19833-Jan-07 8:33 
AnswerRe: Server side not firing Pin
Mark J. Miller3-Jan-07 12:19
Mark J. Miller3-Jan-07 12:19 
GeneralRe: Server side not firing Pin
DanB19833-Jan-07 22:23
DanB19833-Jan-07 22:23 
GeneralRe: Server side not firing Pin
Mark J. Miller4-Jan-07 2:38
Mark J. Miller4-Jan-07 2:38 
GeneralRe: Server side not firing Pin
DanB19834-Jan-07 3:16
DanB19834-Jan-07 3:16 
QuestionReports in .net Pin
Smiles743-Jan-07 7:17
Smiles743-Jan-07 7:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.