Click here to Skip to main content
15,884,388 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Problem with Security Information Message Pop Up Box Pin
AndyASPVB23-Dec-10 0:01
AndyASPVB23-Dec-10 0:01 
Questionhow to put picture from dtatabase to pictureBox in asp.net ? Pin
Gali197821-Dec-10 9:38
Gali197821-Dec-10 9:38 
AnswerRe: how to put picture from dtatabase to pictureBox in asp.net ? Pin
Not Active21-Dec-10 9:56
mentorNot Active21-Dec-10 9:56 
AnswerRe: how to put picture from dtatabase to pictureBox in asp.net ? Pin
saman padidar22-Dec-10 0:51
saman padidar22-Dec-10 0:51 
GeneralRe: how to put picture from dtatabase to pictureBox in asp.net ? Pin
goldsoft22-Dec-10 3:19
goldsoft22-Dec-10 3:19 
GeneralRe: how to put picture from dtatabase to pictureBox in asp.net ? Pin
Not Active22-Dec-10 3:43
mentorNot Active22-Dec-10 3:43 
QuestionBulk updating values from GridView bound to a datatable [moved] Pin
6,921,364 and growing21-Dec-10 2:47
6,921,364 and growing21-Dec-10 2:47 
AnswerRe: Bulk updating values from GridView bound to a datatable [moved] Pin
6,921,364 and growing23-Dec-10 1:33
6,921,364 and growing23-Dec-10 1:33 
I finally got that working. It was simple as I expected just that I didn't put much effort.

This is what I did:
User does the required edits (unchecking the checkbox for not received and editing the exact received quantity) an select 'Save'.
On Save button click,
I get the old data which was saved in ViewState into a datatable. Now I compare the GridView values to the values in DataTale (old values). If it has changed, I edit the value in the datatable. This changes the RowState of that row in the datatable.
The code seems like this:
C#
DataTable dtChallanDtl = new DataTable();
        dtChallanDtl = (DataTable)ViewState["ChallanDtl"];
        int i = 0;
        int ChallanRcvd = 1;
        foreach (GridViewRow r in gvChallanDtl.Rows)
        {
            CheckBox chk = (CheckBox)r.FindControl("CheckSelect");
            TextBox txt = (TextBox)r.FindControl("txtRecvQty");
            if (chk.Checked == true)
            {
                dtChallanDtl.Rows[i]["Received"] = 1;
            }
            else
            {
                ChallanRcvd = 2;
            }
            if (dtChallanDtl.Rows[i]["RecvQty"].ToString() != txt.Text)
            {
                dtChallanDtl.Rows[i]["RecvQty"] = txt.Text;
                dtChallanDtl.Rows[i]["Received"] = 2;
                ChallanRcvd = 2;
            }
            i++;
        }


Here, the variable 'ChallanRcvd' represents the database column which stores the received status of the challan. 0-not received, 1-received, 2-partailly received.

Now I do a bulk update using SqlDataAdapter's Update method.
The important things here are:
SqlDataAdapterObj.UpdateBatchSize = 4; //how many records need to be updated in each batch.
SqlCommandObj.UpdatedRowSource = UpdateRowSource.None; //how command results are applied to the datarow.

After all parameters are supplied, call SqlDataAdapterObj.Update(dtChallanDtl);

I posted this question here because I couldn't find any example on bulk edit using GridView bound to a datatable.
I hope it helps someone.

Regards
Test
QuestionExport DataGrid to Excel Problem with Code. Pin
Asif Rehman21-Dec-10 1:08
Asif Rehman21-Dec-10 1:08 
AnswerRe: Export DataGrid to Excel Problem with Code. Pin
thatraja23-Dec-10 7:26
professionalthatraja23-Dec-10 7:26 
AnswerRe: Export DataGrid to Excel Problem with Code. Pin
Srinivas_Kotra24-Dec-10 3:32
Srinivas_Kotra24-Dec-10 3:32 
QuestionDynamically Add Tabs in Tabcontainer Ajaxtoolkit3.0 Pin
idreesbadshah20-Dec-10 21:19
idreesbadshah20-Dec-10 21:19 
AnswerRe: Dynamically Add Tabs in Tabcontainer Ajaxtoolkit3.0 Pin
Tej Aj21-Dec-10 6:02
Tej Aj21-Dec-10 6:02 
Questionscan a photo by asp.net Pin
mehrnoosh20-Dec-10 20:49
mehrnoosh20-Dec-10 20:49 
AnswerRe: scan a photo by asp.net Pin
Pete O'Hanlon20-Dec-10 21:41
mvePete O'Hanlon20-Dec-10 21:41 
AnswerRe: scan a photo by asp.net Pin
Sajjan Kr Mishra21-Dec-10 4:30
Sajjan Kr Mishra21-Dec-10 4:30 
GeneralRe: scan a photo by asp.net Pin
mehrnoosh21-Dec-10 18:24
mehrnoosh21-Dec-10 18:24 
QuestionMessage Removed Pin
20-Dec-10 19:44
Ravi Mori20-Dec-10 19:44 
AnswerRe: IIS hosting Pin
RaviRanjanKr20-Dec-10 20:57
professionalRaviRanjanKr20-Dec-10 20:57 
GeneralMessage Removed Pin
20-Dec-10 22:55
Ravi Mori20-Dec-10 22:55 
GeneralRe: IIS hosting Pin
RaviRanjanKr21-Dec-10 1:31
professionalRaviRanjanKr21-Dec-10 1:31 
GeneralRe: IIS hosting Pin
thatraja21-Dec-10 2:40
professionalthatraja21-Dec-10 2:40 
GeneralRe: IIS hosting Pin
Ravi Mori21-Dec-10 3:09
Ravi Mori21-Dec-10 3:09 
QuestionNon-English Language in ASP.NET Pin
Mohamed Ibrahim Omar20-Dec-10 12:24
Mohamed Ibrahim Omar20-Dec-10 12:24 
AnswerRe: Non-English Language in ASP.NET Pin
Hiren solanki20-Dec-10 19:16
Hiren solanki20-Dec-10 19:16 

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.