Sunday, July 20, 2008

RadioButtons in gridview. Select one at a time

Hi,

This is another problem I just solved. I found all possible stuff on the internet and no one had solved it in an easier fashion. Though people might call it JUGAD Tech but I must say what I have made just worked for me.

The problem with using radio buttons in a gridview is that even if u use the groupname property of the radio button it will select multiple radio buttons.

So what i did is
1. To the column tag of the gridview add the following code



2. make this function in your .CS file
protected void uncheckOthers(object sender, EventArgs e)
{

int count = GridView1.Rows.Count;
for (int i = 0; i < count; i++)
{
RadioButton rb = (RadioButton)GridView1.Rows[i].Cells[0].FindControl("selectItem");
rb.Checked = false;
}
RadioButton test=(RadioButton)sender;
test.Checked = true;

}

Isn't it easy..


Cheers!!!
Vaibhav

Wednesday, July 16, 2008

Fetching data into a variable from SqlDataSource in Asp.NET with C#

After my struggle of 3 hours I finally got it working. I thought it would be easy but MSDN was of no help at all and the web is full of all the stupid stuff but not the correct information. People just put in the concept and nobody even bothers to write down the steps to fetch the data after the execution of query.

Here is the code I made with the help of a post on some discussion forum. The title of the topic i read was "Getting Variable value out of a SqlDataSource in asp 2.0".

Following is the automatically generated markup when you configure the sqldatasource from the data tab.



Then to you onclick function just add the following lines:

protected bool CustomerAuthenticate(string username, string password)
{

DataView dv = ((System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty)));

TextBox1.Text=dv.Table.Rows[0]["password"].ToString();


//check and return
}


I hope it will help

Saturday, July 12, 2008

Master Pages and Themes in .NET

following are a few nice links for master pages and themes that can be used in .NET. I will be using them for my final project for my Internet Programming course.

http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx
http://www.simple-talk.com/dotnet/asp.net/beginning-asp.net-2.0/
http://msdn.microsoft.com/en-us/magazine/cc163967.aspx
http://www.odetocode.com/articles/450.aspx
http://www.west-wind.com/WebLog/posts/4899.aspx

Special thanks to Dr. Fawcett.


Vaibhav